pub struct Pattern<S = usize, A = DenseDFA<Vec<S>, S>> where
    S: StateID,
    A: DFA<ID = S>, 
{ /* private fields */ }
Expand description

A compiled match pattern that can match multipe inputs, or return a Matcher that matches a single input.

Implementations

Returns a new Pattern for the given regex, or an error if the regex was invalid.

Returns true if this pattern matches the given string.

Returns true if this pattern matches the formatted output of the given type implementing fmt::Debug.

For example:

use matchers::Pattern;

#[derive(Debug)]
pub struct Hello {
    to: &'static str,
}

let pattern = Pattern::new(r#"Hello \{ to: "W[^"]*" \}"#).unwrap();

let hello_world = Hello { to: "World" };
assert!(pattern.debug_matches(&hello_world));

let hello_sf = Hello { to: "San Francisco" };
assert_eq!(pattern.debug_matches(&hello_sf), false);

let hello_washington = Hello { to: "Washington" };
assert!(pattern.debug_matches(&hello_washington));

Returns true if this pattern matches the formatted output of the given type implementing fmt::Display.

For example:

use matchers::Pattern;

#[derive(Debug)]
pub struct Hello {
    to: &'static str,
}

impl fmt::Display for Hello {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "Hello {}", self.to)
    }
}

let pattern = Pattern::new("Hello [Ww].+").unwrap();

let hello_world = Hello { to: "world" };
assert!(pattern.display_matches(&hello_world));
assert_eq!(pattern.debug_matches(&hello_world), false);

let hello_sf = Hello { to: "San Francisco" };
assert_eq!(pattern.display_matches(&hello_sf), false);

let hello_washington = Hello { to: "Washington" };
assert!(pattern.display_matches(&hello_washington));

Returns either a bool indicating whether or not this pattern matches the data read from the provided io::Read stream, or an io::Error if an error occurred reading from the stream.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. 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 resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

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.