pub struct List<T: Pattern> {
pub patterns: Vec<Mapping<T::Value>>,
pub source: Option<PathBuf>,
pub base: Option<BString>,
}
Expand description
A list of patterns which optionally know where they were loaded from and what their base is.
Knowing their base which is relative to a source directory, it will ignore all path to match against that don’t also start with said base.
Fields§
§patterns: Vec<Mapping<T::Value>>
Patterns and their associated data in the order they were loaded in or specified,
the line number in its source file or its sequence number ((pattern, value, line_number)
).
During matching, this order is reversed.
source: Option<PathBuf>
The path from which the patterns were read, or None
if the patterns
don’t originate in a file on disk.
base: Option<BString>
The parent directory of source, or None
if the patterns are global to match against the repository root.
It’s processed to contain slashes only and to end with a trailing slash, and is relative to the repository root.
Implementations§
source§impl<T> List<T>where
T: Pattern,
impl<T> List<T>where
T: Pattern,
Instantiation
sourcepub fn from_bytes(
bytes: &[u8],
source_file: PathBuf,
root: Option<&Path>,
) -> Self
pub fn from_bytes( bytes: &[u8], source_file: PathBuf, root: Option<&Path>, ) -> Self
source_file
is the location of the bytes
which represents a list of patterns, one pattern per line.
If root
is Some(…)
it’s used to see source_file
as relative to itself, if source_file
is absolute.
If source is relative and should be treated as base, set root
to Some("")
.
sourcepub fn from_file(
source: impl Into<PathBuf>,
root: Option<&Path>,
follow_symlinks: bool,
buf: &mut Vec<u8>,
) -> Result<Option<Self>>
pub fn from_file( source: impl Into<PathBuf>, root: Option<&Path>, follow_symlinks: bool, buf: &mut Vec<u8>, ) -> Result<Option<Self>>
Create a pattern list from the source
file, which may be located underneath root
, while optionally
following symlinks with follow_symlinks
, providing buf
to temporarily store the data contained in the file.
source§impl<T> List<T>where
T: Pattern,
impl<T> List<T>where
T: Pattern,
Utilities
sourcepub fn strip_base_handle_recompute_basename_pos<'a>(
&self,
relative_path: &'a BStr,
basename_pos: Option<usize>,
case: Case,
) -> Option<(&'a BStr, Option<usize>)>
pub fn strip_base_handle_recompute_basename_pos<'a>( &self, relative_path: &'a BStr, basename_pos: Option<usize>, case: Case, ) -> Option<(&'a BStr, Option<usize>)>
If this list is anchored to a base path, return relative_path
as being relative to our base and return
an updated basename_pos
as well if it was set.
case
is respected for the comparison.
This is useful to turn repository-relative paths into paths relative to a particular search base.
Trait Implementations§
source§impl<T: Ord + Pattern> Ord for List<T>
impl<T: Ord + Pattern> Ord for List<T>
source§impl<T: PartialOrd + Pattern> PartialOrd for List<T>where
T::Value: PartialOrd,
impl<T: PartialOrd + Pattern> PartialOrd for List<T>where
T::Value: PartialOrd,
impl<T: Eq + Pattern> Eq for List<T>
impl<T: Pattern> StructuralPartialEq for List<T>
Auto Trait Implementations§
impl<T> Freeze for List<T>
impl<T> RefUnwindSafe for List<T>
impl<T> Send for List<T>
impl<T> Sync for List<T>
impl<T> Unpin for List<T>
impl<T> UnwindSafe for List<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)