Trait RegexPattern

Source
pub trait RegexPattern {
    type Error;
    type Output;

    // Required method
    fn try_into_regex(self) -> Result<Self::Output, Self::Error>;

    // Provided method
    fn into_regex(self) -> Self::Output
       where Self: Sized,
             Self::Error: Debug { ... }
}
Expand description

A trait representing types that can be converted into a compiled Regex pattern.

This is used by the regex parser to generically accept either a &str or an already-compiled Regex object. Implementors of this trait can be converted into a Regex via the [try_into_regex] method, allowing flexible API usage.

§Associated Types

  • Error: The error type returned if regex compilation fails.

§Required Methods

  • try_into_regex(self) -> Result<Regex, Self::Error>: Attempts to compile or convert the input into a Regex object.

Required Associated Types§

Required Methods§

Source

fn try_into_regex(self) -> Result<Self::Output, Self::Error>

Provided Methods§

Source

fn into_regex(self) -> Self::Output
where Self: Sized, Self::Error: Debug,

Converts the pattern into a regex, panicking if it fails.

§Panics

Panics if the regex pattern fails to compile.

Implementations on Foreign Types§

Source§

impl RegexPattern for &str

Source§

impl RegexPattern for String

Source§

impl RegexPattern for Regex

Source§

impl RegexPattern for Regex

Implementors§