diff --git a/src/walk/glob.rs b/src/walk/glob.rs index 514a2cc..fdfda2f 100644 --- a/src/walk/glob.rs +++ b/src/walk/glob.rs @@ -195,13 +195,13 @@ struct Anchor { /// [`WalkEntry`]: crate::WalkEntry #[cfg_attr(docsrs, doc(cfg(feature = "walk")))] #[derive(Clone, Debug)] -pub struct WalkNegation { +pub struct FilterAny { exhaustive: Regex, nonexhaustive: Regex, } -impl WalkNegation { - /// Combines glob expressions into a `WalkNegation`. +impl FilterAny { + /// Combines glob expressions into a `FilterAny`. /// /// This function accepts an [`IntoIterator`] with items that implement [`Combine`], such as /// [`Glob`] and `&str`. @@ -228,7 +228,7 @@ impl WalkNegation { .map_err(Into::into)? .into_iter() .partition::, _>(|tree| token::is_exhaustive(tree.as_ref().tokens())); - let negation = WalkNegation { + let negation = FilterAny { exhaustive: crate::any(exhaustive)?.pattern, nonexhaustive: crate::any(nonexhaustive)?.pattern, }; diff --git a/src/walk/mod.rs b/src/walk/mod.rs index ff0a7e1..ac8b7d2 100644 --- a/src/walk/mod.rs +++ b/src/walk/mod.rs @@ -1,12 +1,12 @@ #![cfg(feature = "walk")] -// TODO: Are `cfg(feature = "walk")` attributes redundant on items defined within this module? +// TODO: Are `doc(cfg(feature = "walk"))` attributes redundant on items defined within this module? mod filter; mod glob; mod tree; -pub use crate::walk::glob::{GlobEntry, WalkGlob, WalkNegation}; +pub use crate::walk::glob::{GlobEntry, WalkGlob}; pub use crate::walk::tree::{ EntryResidue, FileIterator, FilterEntry, LinkBehavior, Not, WalkBehavior, WalkEntry, WalkError, WalkTree, diff --git a/src/walk/tree.rs b/src/walk/tree.rs index 9f552ef..a366f68 100644 --- a/src/walk/tree.rs +++ b/src/walk/tree.rs @@ -8,7 +8,7 @@ use crate::walk::filter::{ self, HierarchicalIterator, Isomeric, SeparatingFilter, SeparatingFilterInput, Separation, SkipTree, TreeResidue, WalkCancellation, }; -use crate::walk::glob::WalkNegation; +use crate::walk::glob::FilterAny; use crate::{BuildError, Combine}; pub type FileFiltrate = Result; @@ -384,10 +384,6 @@ impl SeparatingFilterInput for WalkTree { type Feed = (Result, TreeResidue); } -// TODO: This differing behavior is perhaps a bit more intuitive, but less flexible than -// `skip_current_dir`'s behavior. Crucially, `SkipTree` makes it extremely difficult to -// discard a directory in file tree based on its contents, such as some file with a name that -// indicates that a directory should be ignored, etc. impl SkipTree for WalkTree { fn skip_tree(&mut self) { // `IntoIter::skip_current_dir` discards the least recently yielded directory, but @@ -543,9 +539,9 @@ pub trait FileIterator: I: IntoIterator, I::Item: Combine<'t>, { - WalkNegation::any(patterns).map(|negation| Not { + FilterAny::any(patterns).map(|filter| Not { input: self, - negation, + filter, }) } } @@ -558,7 +554,7 @@ where } // TODO: Implement this using combinators provided by the `filter` module and RPITIT once it lands -// in stable Rust. Remove any use of `WalkCancellation::unchecked`. +// in stable Rust. Remove any use of `WalkCancellation::unchecked`. /// Iterator adaptor that filters [`WalkEntry`]s and controls the traversal of directory trees. /// /// This adaptor is returned by [`FileIterator::filter_tree`] and in addition to filtering @@ -632,7 +628,7 @@ where #[derive(Clone, Debug)] pub struct Not { input: I, - negation: WalkNegation, + filter: FilterAny, } impl SeparatingFilter for Not @@ -650,7 +646,7 @@ where Ok(separation) => separation .filter_tree_by_substituent( WalkCancellation::unchecked(&mut self.input), - |substituent| self.negation.residue(substituent).map(From::from), + |substituent| self.filter.residue(substituent).map(From::from), ) .map_filtrate(Ok), Err(error) => error.map(Err).into(),