Skip to main content

IgnoreRules

Struct IgnoreRules 

Source
pub struct IgnoreRules { /* private fields */ }
Expand description

管理文件和目录的忽略规则。 使用 Gitignore 语法来匹配路径。

Implementations§

Source§

impl IgnoreRules

Source

pub fn new(rules: &[String], base_dir: &Path) -> Result<Self>

创建新的 IgnoreRules 实例。

§参数
  • rules: 忽略规则的字符串切片。
  • base_dir: 基础目录,所有路径都将相对于此目录进行匹配。
§返回

Result<Self>: 成功时返回 IgnoreRules 实例,失败时返回错误信息。

Source

pub fn should_ignore(&self, path: &Path, is_dir: bool) -> bool

检查给定的路径是否应该被忽略。

§参数
  • path: 要检查的路径。
  • is_dir: 指示路径是否是目录。
§返回

bool: 如果路径应该被忽略,则返回 true,否则返回 false

Source

pub fn filter_files<I>(&self, files_to_filter: I) -> Result<Vec<PathBuf>>
where I: Iterator<Item = PathBuf>,

过滤给定的文件路径列表,移除所有应该被忽略的文件。

§参数
  • files_to_filter: 一个包含文件路径的迭代器。
§返回

Result<Vec<PathBuf>>: 包含所有不被忽略的文件路径的向量。

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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.
Source§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.