[][src]Struct metadata_filter::rules::FilterRule

pub struct FilterRule(_, _);

Represents a regex replacement rule with a pattern and replacement text.

Implementations

impl FilterRule[src]

pub fn new(pattern: &str, replacement: &str) -> Result<Self, Box<dyn Error>>[src]

Create a new filter rule with a pattern and a replacement text. The pattern follows the syntax from the regex crate. Returns an error if the regex could not be compiled.

pub fn apply<'t>(&self, text: &'t str) -> Cow<'t, str>[src]

Apply the filter rule. Returns Cow::Owned if a replacement was done, or Cow::Borrowed (referencing the original text) if nothing was changed.

Trait Implementations

impl Clone for FilterRule[src]

impl Debug for FilterRule[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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> 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.