pub struct GitignoreBuilder { /* private fields */ }
Expand description

Builds a matcher for a single set of globs from a .gitignore file.

Implementations§

source§

impl GitignoreBuilder

source

pub fn new<P: AsRef<Path>>(root: P) -> GitignoreBuilder

Create a new builder for a gitignore file.

The path given should be the path at which the globs for this gitignore file should be matched. Note that paths are always matched relative to the root path given here. Generally, the root path should correspond to the directory containing a .gitignore file.

source

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

Builds a new matcher from the globs added so far.

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

source

pub fn build_global(self) -> (Gitignore, Option<Error>)

Build a global gitignore matcher using the configuration in this builder.

This consumes ownership of the builder unlike build because it must mutate the builder to add the global gitignore globs.

Note that this ignores the path given to this builder’s constructor and instead derives the path automatically from git’s global configuration.

source

pub fn add<P: AsRef<Path>>(&mut self, path: P) -> Option<Error>

Add each glob from the file path given.

The file given should be formatted as a gitignore file.

Note that partial errors can be returned. For example, if there was a problem adding one glob, an error for that will be returned, but all other valid globs will still be added.

source

pub fn add_line( &mut self, from: Option<PathBuf>, line: &str ) -> Result<&mut GitignoreBuilder, Error>

Add a line from a gitignore file to this builder.

If this line came from a particular gitignore file, then its path should be provided here.

If the line could not be parsed as a glob, then an error is returned.

source

pub fn case_insensitive( &mut self, yes: bool ) -> Result<&mut GitignoreBuilder, 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.

Trait Implementations§

source§

impl Clone for GitignoreBuilder

source§

fn clone(&self) -> GitignoreBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for GitignoreBuilder

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.