pub struct GlobSet<'a> { /* private fields */ }
Expand description

Glob set

This struct contains a set of Glob’s.

Notes

For #![no_std]: this struct uses a vector inside. Since at the time of implementation, HashSet was not available.

Implementations

Makes new instance from an iterator of Cow<'a, str>
Notes
  • Empty strings will be ignored.
  • If the iterator contains no globs, None is returned.
  • For #![no_std] users: this function takes little effort to remove duplicates. You should help with that yourself (by not providing duplicates).
Examples
use sub_strs::GlobSet;

let glob_set = GlobSet::from_iter("*.rs|*.md".split('|').map(|s| s.into())).unwrap();
assert!(glob_set.any("this.rs"));
assert!(glob_set.any("that.md"));
assert!(glob_set.any("not-this") == false);
Merges an iterator of GlobSet<'a> into one
Notes
  • If there are no inner Glob’s, None is returned.
  • For #![no_std] users: this function takes little effort to remove duplicates. You should help with that yourself (by not providing duplicates).
Examples
use sub_strs::GlobSet;

let program_args = &["*.svg,*.OGG", "*.md"];
let glob_set = GlobSet::merge(
    program_args.iter().filter_map(|s|
        GlobSet::from_iter(s.to_lowercase().split(',').map(|s| s.to_string().into()))
    )
);
assert!(glob_set.map(|g| g.any("some.ogg")).unwrap_or(false));

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.