[][src]Struct sub_strs::GlobSet

pub struct GlobSet<'a> { /* fields omitted */ }

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.

Methods

impl<'a> GlobSet<'a>[src]

pub fn from<I>(strs: I) -> Option<Self> where
    I: Iterator<Item = Cow<'a, str>>, 
[src]

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("*.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);

pub fn merge<I>(iter: I) -> Option<Self> where
    I: Iterator<Item = Self>, 
[src]

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(s.to_lowercase().split(',').map(|s| s.to_string().into()))
    )
);
assert!(glob_set.map(|g| g.any("some.ogg")).unwrap_or(false));

pub fn any<S>(&self, s: S) -> bool where
    S: AsRef<str>, 
[src]

Trait Implementations

impl<'a> Debug for GlobSet<'a>[src]

impl<'a> PartialEq<GlobSet<'a>> for GlobSet<'a>[src]

impl<'a> Eq for GlobSet<'a>[src]

impl<'a> StructuralPartialEq for GlobSet<'a>[src]

impl<'a> StructuralEq for GlobSet<'a>[src]

Auto Trait Implementations

impl<'a> Unpin for GlobSet<'a>

impl<'a> Send for GlobSet<'a>

impl<'a> Sync for GlobSet<'a>

impl<'a> UnwindSafe for GlobSet<'a>

impl<'a> RefUnwindSafe for GlobSet<'a>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]