Trait onig::Replacer

source ·
pub trait Replacer {
    // Required method
    fn reg_replace(&mut self, caps: &Captures<'_>) -> Cow<'_, str>;
}
Expand description

Replacer describes types that can be used to replace matches in a string.

Implementations are provided for replacement using string literals and FnMut callbacks. If this isn’t enough for your replacement needs a user-supplied Replacer implemenation can be provided. For an example of a custom replacer implementation check out examples/dollar.rs in the Onig crate.

Required Methods§

source

fn reg_replace(&mut self, caps: &Captures<'_>) -> Cow<'_, str>

Returns a possibly owned string that is used to replace the match corresponding to the caps capture group.

Implementations on Foreign Types§

source§

impl<'t> Replacer for &'t str

Replacement using Literal Strings

source§

fn reg_replace(&mut self, _: &Captures<'_>) -> Cow<'_, str>

Implementors§

source§

impl<F> Replacer for F
where F: FnMut(&Captures<'_>) -> String,

Replacement using FnMut Callbacks