diff options
author | sharkdp <davidpeter@web.de> | 2017-09-17 09:37:39 +0200 |
---|---|---|
committer | sharkdp <davidpeter@web.de> | 2017-09-17 09:37:39 +0200 |
commit | c1b8d1eae19c8b0490bdec5e649ea089dcab9e12 (patch) | |
tree | a6c139f063804ae100c4829aab4f7e0d5c322d1d | |
parent | 2a3dd5b63181bda6067517d76269d8b3b0204a05 (diff) |
Minor style changesv3.1.0
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/main.rs | 37 |
3 files changed, 21 insertions, 20 deletions
@@ -1,6 +1,6 @@ [root] name = "fd-find" -version = "3.0.0" +version = "3.1.0" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1,6 +1,6 @@ [package] name = "fd-find" -version = "3.0.0" +version = "3.1.0" authors = ["David Peter <mail@david-peter.de>"] description = "fd is a simple, fast and user-friendly alternative to find." homepage = "https://github.com/sharkdp/fd" diff --git a/src/main.rs b/src/main.rs index 9e0ef75..b2d88bb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,6 +40,15 @@ enum PathDisplay { Relative } +/// The type of file to search for. +#[derive(Copy, Clone)] +enum FileType { + Any, + RegularFile, + Directory, + SymLink +} + /// Configuration options for *fd*. struct FdOptions { /// Determines whether the regex search is case-sensitive or case-insensitive. @@ -82,18 +91,10 @@ struct FdOptions { /// how to style different filetypes. ls_colors: Option<LsColors>, + /// The type of file to search for. All files other than the specified type will be ignored. file_type: FileType, } -/// The type of file to search for. All files other than the specified type will be ignored. -#[derive(Copy, Clone)] -enum FileType { - Any, - RegularFile, - Directory, - SymLink, -} - /// The receiver thread can either be buffering results or directly streaming to the console. enum ReceiverMode { /// Receiver is still buffering in order to sort the results, if the search finishes fast @@ -289,13 +290,13 @@ fn scan(root: &Path, pattern: Arc<Regex>, base: &Path, config: Arc<FdOptions>) { match config.file_type { FileType::Any => (), FileType::RegularFile => if entry.file_type().map_or(false, |ft| !ft.is_file()) { - return ignore::WalkState::Continue; + return ignore::WalkState::Continue; }, FileType::Directory => if entry.file_type().map_or(false, |ft| !ft.is_dir()) { - return ignore::WalkState::Continue; + return ignore::WalkState::Continue; }, FileType::SymLink => if entry.file_type().map_or(false, |ft| !ft.is_symlink()) { - return ignore::WalkState::Continue; + return ignore::WalkState::Continue; }, } @@ -480,12 +481,12 @@ fn main() { PathDisplay::Relative }, ls_colors: ls_colors, - file_type: match matches.value_of("file-type") { - Some("f") | Some("file") => FileType::RegularFile, - Some("d") | Some("directory") => FileType::Directory, - Some("s") | Some("symlink") => FileType::SymLink, - _ => FileType::Any, - }, + file_type: match matches.value_of("file-type") { + Some("f") | Some("file") => FileType::RegularFile, + Some("d") | Some("directory") => FileType::Directory, + Some("s") | Some("symlink") => FileType::SymLink, + _ => FileType::Any, + }, }; let root = Path::new(ROOT_DIR); |