Skip to main content

Replace

Trait Replace 

Source
pub trait Replace<'a> {
    // Required methods
    fn replace_cow<P: Pattern>(self, from: P, to: &str) -> Cow<'a, str>;
    fn replacen_cow<P: Pattern>(
        self,
        from: P,
        to: &str,
        count: usize,
    ) -> Cow<'a, str>;
}
Available on crate feature alloc only.
Expand description

To extend str and Cow<str> to have replace_cow and replacen_cow methods.

Required Methods§

Source

fn replace_cow<P: Pattern>(self, from: P, to: &str) -> Cow<'a, str>

Replaces all matches of a pattern with another string, returning a Cow<str> to avoid allocation when possible.

Source

fn replacen_cow<P: Pattern>( self, from: P, to: &str, count: usize, ) -> Cow<'a, str>

Replaces at most count matches of a pattern with another string, returning a Cow<str> to avoid allocation when possible.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a> Replace<'a> for &'a str

Source§

fn replace_cow<P: Pattern>(self, from: P, to: &str) -> Cow<'a, str>

Source§

fn replacen_cow<P: Pattern>( self, from: P, to: &str, count: usize, ) -> Cow<'a, str>

Source§

impl<'a> Replace<'a> for Cow<'a, str>

Source§

fn replace_cow<P: Pattern>(self, from: P, to: &str) -> Cow<'a, str>

Source§

fn replacen_cow<P: Pattern>( self, from: P, to: &str, count: usize, ) -> Cow<'a, str>

Implementors§