Struct OverrideBuilder

pub struct OverrideBuilder { /* private fields */ }

Builds a matcher for a set of glob overrides.

Implementations

impl OverrideBuilder

fn new<P: AsRef<Path>>(path: P) -> OverrideBuilder

Create a new override builder.

Matching is done relative to the directory path provided.

fn build(&self) -> Result<Override, Error>

Builds a new override matcher from the globs added so far.

Once a matcher is built, no new globs can be added to it.

fn add(&mut self, glob: &str) -> Result<&mut OverrideBuilder, Error>

Add a glob to the set of overrides.

Globs provided here have precisely the same semantics as a single line in a gitignore file, where the meaning of ! is inverted: namely, ! at the beginning of a glob will ignore a file. Without !, all matches of the glob provided are treated as whitelist matches.

fn case_insensitive(&mut self, yes: bool) -> Result<&mut OverrideBuilder, Error>

Toggle whether the globs should be matched case insensitively or not.

When this option is changed, only globs added after the change will be affected.

This is disabled by default.

fn allow_unclosed_class(&mut self, yes: bool) -> &mut OverrideBuilder

Toggle whether unclosed character classes are allowed. When allowed, a [ without a matching ] is treated literally instead of resulting in a parse error.

For example, if this is set then the glob [abc will be treated as the literal string [abc instead of returning an error.

By default, this is false. Generally speaking, enabling this leads to worse failure modes since the glob parser becomes more permissive. You might want to enable this when compatibility (e.g., with POSIX glob implementations) is more important than good error messages.

This default is different from the default for Gitignore. Namely, Gitignore is intended to match git's behavior as-is. But this abstraction for "override" globs does not necessarily conform to any other known specification and instead prioritizes better error messages.

Trait Implementations

impl Clone for OverrideBuilder

fn clone(&self) -> OverrideBuilder

impl Debug for OverrideBuilder

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl Freeze for OverrideBuilder

impl RefUnwindSafe for OverrideBuilder

impl Send for OverrideBuilder

impl Sync for OverrideBuilder

impl Unpin for OverrideBuilder

impl UnsafeUnpin for OverrideBuilder

impl UnwindSafe for OverrideBuilder

Blanket Implementations

impl<T> Any for OverrideBuilder where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for OverrideBuilder where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for OverrideBuilder where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for OverrideBuilder where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for OverrideBuilder

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Pointable for OverrideBuilder

const ALIGN: usize = _;
type Init = T;
unsafe fn init(init: <T as Pointable>::Init) -> usize
unsafe fn deref<'a>(ptr: usize) -> &'a T
unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
unsafe fn drop(ptr: usize)

impl<T> ToOwned for OverrideBuilder where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for OverrideBuilder where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for OverrideBuilder where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for OverrideBuilder where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>