mod path_matcher_and;
#[doc(hidden)]
pub mod path_matcher_any;
mod path_matcher_equal;
mod path_matcher_func;
#[cfg(feature = "glob")]
mod path_matcher_glob;
mod path_matcher_not;
mod path_matcher_or;
mod path_matcher_starts_with;
#[cfg(test)]
mod path_matcher_true;
use std::path::Path;
pub trait PathMatcher {
fn matches(&self, path: &Path) -> bool;
fn boxed<'a>(self) -> Box<dyn PathMatcher + 'a>
where
Self: Sized + 'a,
{
Box::new(self)
}
}
pub trait PathMatcherExt: PathMatcher + Sized {
fn and<R: PathMatcher>(self, right: R) -> PathMatcherAnd<Self, R> {
PathMatcherAnd(self, right)
}
fn or<R: PathMatcher>(self, right: R) -> PathMatcherOr<Self, R> {
PathMatcherOr(self, right)
}
}
impl<F> PathMatcherExt for F where F: PathMatcher + Sized {}
impl<F> PathMatcher for F
where
F: Fn(&Path) -> bool,
{
fn matches(&self, path: &Path) -> bool {
self(path)
}
}
pub use path_matcher_and::and;
use path_matcher_and::PathMatcherAnd;
pub use path_matcher_any::any_of;
pub use path_matcher_equal::equal;
pub use path_matcher_func::func;
#[cfg(feature = "glob")]
pub use path_matcher_glob::{glob, PatternError};
pub use path_matcher_not::not;
pub use path_matcher_or::or;
use path_matcher_or::PathMatcherOr;
pub use path_matcher_starts_with::starts_with;