From 47fe04dfb634eba3c24403013cf92960237cf761 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Wed, 30 Nov 2022 03:11:38 -0600 Subject: revert: remove figment from the lib (moved to bin) --- src/search.rs | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) (limited to 'src/search.rs') diff --git a/src/search.rs b/src/search.rs index 6249da4..fc794ea 100644 --- a/src/search.rs +++ b/src/search.rs @@ -1,14 +1,13 @@ -use figment::Provider; -use std::vec::IntoIter; - -use self::entry::EntryIter; -use crate::{config::Entry, project::ProjectItem, Config, Result}; +use self::entry::SearchEntry; +use crate::{config::SearchEntryConfig, project::ProjectItem}; pub mod entry; +type EntryIter = std::vec::IntoIter; + pub struct Search { - iter: IntoIter, - curr: Option, + iter: EntryIter, + curr: Option, } impl std::fmt::Debug for Search { @@ -19,28 +18,9 @@ impl std::fmt::Debug for Search { } } -impl Search { - pub fn new() -> Result { - Self::from_provider(Config::figment()) - } - - /// Extract `Config` from `provider` to construct new `Paths` - pub fn from_provider(provider: T) -> Result { - Config::extract(&provider) - .map_err(Into::into) - .map(|config| config.paths.into()) - } -} - -impl From for Search { - fn from(config: Config) -> Self { - config.paths.into() - } -} - impl From for Search where - T: IntoIterator>, + T: IntoIterator, { fn from(value: T) -> Self { Self { @@ -86,17 +66,17 @@ mod tests { let project4 = temp_dir.join("subdir/project4"); let paths = Search::from(Vec::from([ - Entry { + SearchEntryConfig { path_buf: project_dir.to_owned(), max_depth: Some(1), ..Default::default() }, - Entry { + SearchEntryConfig { path_buf: project3.to_owned(), max_depth: Some(0), ..Default::default() }, - Entry { + SearchEntryConfig { path_buf: project4.to_owned(), max_depth: Some(0), ..Default::default() -- cgit v1.2.3-70-g09d2