Skip to content

Commit c2ece9f

Browse files
Change find_file to be a more generic find
1 parent 4b109fa commit c2ece9f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "simpath"
3-
version = "1.0.0"
3+
version = "1.1.0"
44
authors = ["Andrew Mackenzie <[email protected]>"]
55
description = "Search for files on a path defined in an environment variable"
66
license = "MIT"

src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Simpath {
2626
///
2727
/// fn main() {
2828
/// let search_path = Simpath::new("PATH");
29-
/// let ls_file = search_path.find_file("ls");
29+
/// let ls_file = search_path.find("ls");
3030
/// match ls_file {
3131
/// Ok(path) => println!("'ls' was found at '{}'", path.display()),
3232
/// Err(e) => println!("{}", e)
@@ -77,14 +77,14 @@ impl Simpath {
7777
///
7878
/// fn main() {
7979
/// let search_path = Simpath::new("PATH");
80-
/// match search_path.find_file("my-file") {
80+
/// match search_path.find("my-file") {
8181
/// Ok(_found_dir) => println!("Didn't expect that!!"),
8282
/// Err(e) => println!("{}", e.to_string())
8383
/// }
8484
/// }
8585
/// ```
8686
///
87-
pub fn find_file(&self, file_name: &str) -> Result<PathBuf, Error> {
87+
pub fn find(&self, file_name: &str) -> Result<PathBuf, Error> {
8888
for search_dir in &self.dirs {
8989
for entry in fs::read_dir(search_dir)? {
9090
let file = entry?;
@@ -94,7 +94,7 @@ impl Simpath {
9494
}
9595
}
9696
Err(Error::new(ErrorKind::NotFound,
97-
format!("Could not find file '{}' in search path '{}'",
97+
format!("Could not find '{}' in search path '{}'",
9898
file_name, self.name)))
9999
}
100100

@@ -201,7 +201,7 @@ mod test {
201201
#[test]
202202
fn find_non_existant_file() {
203203
let path = Simpath::new("MyName");
204-
assert!(path.find_file("no_such_file").is_err());
204+
assert!(path.find("no_such_file").is_err());
205205
}
206206

207207
#[test]

0 commit comments

Comments
 (0)