Skip to main content

Pattern

Struct Pattern 

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

Pattern represents a successfully parsed Relay pattern.

A pattern can be parsed/de-serialized from a string, serializing a pattern again may not produce the same original pattern but a normalized variant of the pattern.

let pattern = Pattern::builder("Foo**").case_insensitive(true).build().unwrap();
assert_eq!(&pattern.to_string(), "foo*");

Patterns can be compared with other patterns, a pattern is considered equal with another pattern if its parsed and normalized forms and options are the same. Two patterns with the same options but built from different strings may compare equal if their normalized forms are the same.

let pattern1 = Pattern::builder("Foo**").case_insensitive(true).build().unwrap();
let pattern2 = Pattern::builder("foo*").case_insensitive(true).build().unwrap();
assert_eq!(&pattern1, &pattern2);

let pattern1 = Pattern::builder("Foo**").case_insensitive(true).build().unwrap();
let pattern2 = Pattern::builder("foo*").case_insensitive(false).build().unwrap();
assert_ne!(&pattern1, &pattern2);

Implementations§

Source§

impl Pattern

Source

pub fn new(pattern: &str) -> Result<Self, Error>

Create a new Pattern from a string with the default settings.

Source

pub fn builder(pattern: &str) -> PatternBuilder<'_>

Create a new PatternBuilder. The builder can be used to adjust the pattern settings.

Source

pub fn is_match(&self, haystack: &str) -> bool

Returns true if the pattern matches the passed string.

Trait Implementations§

Source§

impl<C> AsRef<Pattern> for TypedPattern<C>

Source§

fn as_ref(&self) -> &Pattern

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Pattern

Source§

fn clone(&self) -> Pattern

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Pattern

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Pattern

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Pattern

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Pattern

Source§

impl<C> From<TypedPattern<C>> for Pattern

Source§

fn from(value: TypedPattern<C>) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Pattern

Source§

fn eq(&self, other: &Pattern) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Pattern

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Pattern

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.