From e4cd3b2d98082fe617c98b067f906842cf8d1b5e Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Sun, 6 Nov 2022 22:10:47 +0300 Subject: [PATCH 1/5] Docs improvement --- src/builder.rs | 73 +++++++++++++++++++++++++++----------------------- src/search.rs | 3 +++ 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index c52d4d9..4097f7a 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -6,11 +6,11 @@ use crate::Search; pub struct SearchBuilder { /// The location to search in, defaults to the current directory. search_location: PathBuf, - /// Vector of additional locations to search in. + /// Additional locations to search in. more_locations: Option>, - /// The search input, defaults to search for every word. + /// The search input, default will get all files from locations. search_input: Option, - /// The file extension to search for, defaults to any file extension. + /// The file extension to search for, defaults to get all extensions. file_ext: Option, /// The depth to search to, defaults to no limit. depth: Option, @@ -46,9 +46,9 @@ impl SearchBuilder { /// use rust_search::SearchBuilder; /// /// let search: Vec = SearchBuilder::default() - /// .location("src") - /// .build() - /// .collect(); + /// .location("src") + /// .build() + /// .collect(); /// ``` pub fn location(mut self, location: impl AsRef) -> Self { self.search_location = location.as_ref().to_path_buf(); @@ -63,9 +63,9 @@ impl SearchBuilder { /// use rust_search::SearchBuilder; /// /// let search: Vec = SearchBuilder::default() - /// .search_input("Search") - /// .build() - /// .collect(); + /// .search_input("Search") + /// .build() + /// .collect(); /// ``` pub fn search_input(mut self, input: impl Into) -> Self { self.search_input = Some(input.into()); @@ -80,16 +80,16 @@ impl SearchBuilder { /// use rust_search::SearchBuilder; /// /// let search: Vec = SearchBuilder::default() - /// .ext(".rs") - /// .build() - /// .collect(); + /// .ext(".rs") + /// .build() + /// .collect(); /// ``` pub fn ext(mut self, ext: impl Into) -> Self { self.file_ext = Some(ext.into()); self } - /// Set the depth to search to. + /// Set the depth to search to, meaning how many subdirectories to search in. /// ### Arguments /// * `depth` - The depth to search to. /// ### Examples @@ -97,25 +97,27 @@ impl SearchBuilder { /// use rust_search::SearchBuilder; /// /// let search: Vec = SearchBuilder::default() - /// .depth(1) - /// .build() - /// .collect(); + /// .depth(1) + /// .build() + /// .collect(); /// ``` pub fn depth(mut self, depth: usize) -> Self { self.depth = Some(depth); self } - /// Searches for exact match + /// Searches for exact match. + /// + /// For example, if the search input is "Search", the file "Search.rs" will be found, but not "Searcher.rs". /// ### Examples /// ```rust /// use rust_search::SearchBuilder; /// /// let search: Vec = SearchBuilder::default() - /// .search_input("name") - /// .strict() - /// .build() - /// .collect(); + /// .search_input("name") + /// .strict() + /// .build() + /// .collect(); /// ``` pub fn strict(mut self) -> Self { self.strict = true; @@ -123,47 +125,49 @@ impl SearchBuilder { } /// Set search option to be case insensitive. + /// + /// For example, if the search input is "Search", the file "search.rs" will be found. /// ### Examples /// ```rust /// use rust_search::SearchBuilder; /// /// let search: Vec = SearchBuilder::default() - /// .search_input("name") - /// .ignore_case() - /// .build() - /// .collect(); + /// .search_input("name") + /// .ignore_case() + /// .build() + /// .collect(); /// ``` pub fn ignore_case(mut self) -> Self { self.ignore_case = true; self } - /// Searches for hidden files + /// Searches for hidden files, meaning files that start with a dot. /// ### Examples /// ```rust /// use rust_search::SearchBuilder; /// /// let search: Vec = SearchBuilder::default() - /// .with_hidden() - /// .build() - /// .collect(); + /// .with_hidden() + /// .build() + /// .collect(); /// ``` pub fn hidden(mut self) -> Self { self.hidden = true; self } - /// Add extra locations to search in. + /// Add extra locations to search in, in addition to the main location. /// ### Arguments - /// * `more_locations` - Vec<> of locations to search in. + /// * `more_locations` - locations to search in. /// ### Examples /// ```rust /// use rust_search::SearchBuilder; /// /// let search: Vec = SearchBuilder::default() - /// .more_locations(vec!["/Users/username/b/", "/Users/username/c/"]) - /// .build() - /// .collect(); + /// .more_locations(vec!["/Users/username/b/", "/Users/username/c/"]) + /// .build() + /// .collect(); /// ``` pub fn more_locations(mut self, more_locations: Vec>) -> Self { self.more_locations = Some( @@ -177,6 +181,7 @@ impl SearchBuilder { } impl Default for SearchBuilder { + /// With this default, the search will get all files from the current directory. fn default() -> Self { Self { search_location: std::env::current_dir().expect("Failed to get current directory"), diff --git a/src/search.rs b/src/search.rs index 4392ce6..ef5bbe9 100644 --- a/src/search.rs +++ b/src/search.rs @@ -57,6 +57,9 @@ impl Search { /// * `search_input` - The search input, defaults to any word /// * `file_ext` - The file extension to search for, defaults to any file extension /// * `depth` - The depth to search to, defaults to no limit + /// * `strict` - Whether to search for the exact word or not + /// * `ignore_case` - Whether to ignore case or not + /// * `hidden` - Whether to search hidden files or not, files starting with a dot #[allow(clippy::too_many_arguments)] pub fn new( search_location: impl AsRef, From fe4415ad9510db18bd88e8d3e858d576a322e9cb Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Sun, 6 Nov 2022 22:21:44 +0300 Subject: [PATCH 2/5] Update README.md Nice in center :) --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4892a97..5f605f8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,14 @@ +
+ ![Group 1](https://user-images.githubusercontent.com/42001064/198829818-c4035432-8721-45e1-ba2d-4d2eb6d0c584.svg) -Blazingly fast file search library built in Rust 🔥 [Work in progress] +Blazingly fast file search crate built in Rust 🔥 [![Version info](https://img.shields.io/crates/v/rust_search.svg)](https://crates.io/crates/rust_search) +[![Documentation](https://docs.rs/rust_search/badge.svg)](https://docs.rs/rust_search) +[![License](https://img.shields.io/crates/l/rust_search.svg)](https://github.com/rohitjmathew/rust_search/blob/master/LICENSE-MIT) + +
## 📦 Usage From a1684b0d9b119b34edafe4cf07af5a615d9ad791 Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Sun, 6 Nov 2022 23:06:38 +0300 Subject: [PATCH 3/5] Update README.md Update benchmarks name to `Rust Search` --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5f605f8..c47690a 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ The difference in sample size is due to the fact that fd and glob are different Benchmarks are done using [hyperfine](https://github.com/sharkdp/hyperfine), Benchmarks files are available in the [benchmarks](https://drive.google.com/drive/folders/1ug6ojNixS5jAe6Lh6M0o2d3tku73zQ9w?usp=sharing) drive folder. -### - Rust vs Glob +### - Rust Search vs Glob The benchmark was done on a directories containing 300K files. @@ -91,7 +91,7 @@ The benchmark was done on a directories containing 300K files. --- -### - Rust vs FD +### - Rust Search vs FD The benchmark was done on a directories containing 45K files. @@ -105,9 +105,9 @@ The benchmark was done on a directories containing 45K files. ### Results:- ```diff -+ Rust_Search is 17.25 times faster than Glob. ++ rust_search is 17.25 times faster than Glob. -+ Rust_Search** is 1.09 times faster than FD. ++ rust_search** is 1.09 times faster than FD. ``` ## 👨‍💻 Contributors From 62c1fead81634c01bf34a3759476aa4d98376ba0 Mon Sep 17 00:00:00 2001 From: Awiteb Date: Mon, 7 Nov 2022 10:59:21 +0300 Subject: [PATCH 4/5] Update hidden docs Co-authored-by: Parth Jadhav --- src/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/builder.rs b/src/builder.rs index 4097f7a..87a5937 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -142,7 +142,7 @@ impl SearchBuilder { self } - /// Searches for hidden files, meaning files that start with a dot. + /// Searches for hidden files. /// ### Examples /// ```rust /// use rust_search::SearchBuilder; From 2eb6c387fadb5368019f29a53c384bcea74b2126 Mon Sep 17 00:00:00 2001 From: Awiteb Date: Mon, 7 Nov 2022 10:59:42 +0300 Subject: [PATCH 5/5] Update README.md Fix typo Co-authored-by: Parth Jadhav --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c47690a..225f1ec 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Blazingly fast file search crate built in Rust 🔥 [![Version info](https://img.shields.io/crates/v/rust_search.svg)](https://crates.io/crates/rust_search) [![Documentation](https://docs.rs/rust_search/badge.svg)](https://docs.rs/rust_search) -[![License](https://img.shields.io/crates/l/rust_search.svg)](https://github.com/rohitjmathew/rust_search/blob/master/LICENSE-MIT) +[![License](https://img.shields.io/crates/l/rust_search.svg)](https://github.com/parthjadhav/rust_search/blob/master/LICENSE-MIT)