Skip to content

Commit

Permalink
Rename Negation to WalkNegation.
Browse files Browse the repository at this point in the history
This change renames `Negation` to `WalkNegation` to better reflect this
types usage and close association with matching against directory trees.
  • Loading branch information
olson-sean-k committed Sep 29, 2023
1 parent 13a3e16 commit 291513d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ pub use crate::capture::MatchedText;
pub use crate::diagnostics::{LocatedError, Span};
#[cfg(feature = "walk")]
pub use crate::walk::{
FileIterator, FilterTarget, FilterTree, LinkBehavior, Negation, Walk, WalkBehavior, WalkEntry,
WalkError,
FileIterator, FilterTarget, FilterTree, LinkBehavior, Walk, WalkBehavior, WalkEntry, WalkError,
WalkNegation,
};

#[cfg(windows)]
Expand Down
14 changes: 7 additions & 7 deletions src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,13 @@ impl TreeIterator for walkdir::IntoIter {
/// [`WalkEntry`]: crate::WalkEntry
#[cfg_attr(docsrs, doc(cfg(feature = "walk")))]
#[derive(Clone, Debug)]
pub struct Negation {
pub struct WalkNegation {
exhaustive: Regex,
nonexhaustive: Regex,
}

impl Negation {
/// Combines glob expressions into a `Negation`.
impl WalkNegation {
/// Combines glob expressions into a `WalkNegation`.
///
/// This function accepts an [`IntoIterator`] with items that implement
/// [`Combine`], such as [`Glob`] and `&str`.
Expand All @@ -371,7 +371,7 @@ impl Negation {
.map_err(Into::into)?
.into_iter()
.partition::<Vec<_>, _>(|tree| token::is_exhaustive(tree.as_ref().tokens()));
let negation = Negation {
let negation = WalkNegation {
exhaustive: crate::any(exhaustive)?.pattern,
nonexhaustive: crate::any(nonexhaustive)?.pattern,
};
Expand Down Expand Up @@ -626,7 +626,7 @@ impl<'g> Walk<'g> {
/// matching a [`Glob`] against a directory tree that cannot be achieved
/// using a single glob expression alone.
///
/// The adaptor is constructed via [`FilterTree`] and [`Negation`] and
/// The adaptor is constructed via [`FilterTree`] and [`WalkNegation`] and
/// therefore does not read directory trees from the file system when a
/// directory matches an [exhaustive glob
/// expression][`Pattern::is_exhaustive`] such as `**/private/**` or
Expand Down Expand Up @@ -661,16 +661,16 @@ impl<'g> Walk<'g> {
/// [`FileIterator::filter_tree`]: crate::FileIterator::filter_tree
/// [`Glob`]: crate::Glob
/// [`Iterator::filter`]: std::iter::Iterator::filter
/// [`Negation`]: crate::Negation
/// [`Pattern`]: crate::Pattern
/// [`Pattern::is_exhaustive`]: crate::Pattern::is_exhaustive
/// [`WalkEntry`]: crate::WalkEntry
/// [`WalkNegation`]: crate::WalkNegation
pub fn not<'t, I>(self, patterns: I) -> Result<impl 'g + FileIterator, BuildError>
where
I: IntoIterator,
I::Item: Combine<'t>,
{
Negation::any(patterns)
WalkNegation::any(patterns)
.map(|negation| self.filter_tree(move |entry| negation.target(entry)))
}

Expand Down

0 comments on commit 291513d

Please sign in to comment.