[][src]Struct lazy_string_replace::ReplacedString

pub struct ReplacedString<'a, P, R> { /* fields omitted */ }

A lazily-replaced string - no work is done until you call .to_string() or use format!/write! and friends. This is useful when, for example, doing format!("( {} )", my_string.replace(needle, some_replacement). Since it uses a Display for a replacement, you can even replace a string with a different lazily-replaced string, all without allocating. Of course, this will duplicate work when there is more than one match, but fixing this would require memoization of the Display result, which in turn would require allocation. A memoizing Display wrapper is out of scope for this crate.

Methods

impl<'a, P, R> ReplacedString<'a, P, R>[src]

pub fn new(haystack: &'a str, needle: P, replacement: R) -> Self[src]

Create a struct implementing Display that will display the specified string with the specified pattern replaced with the specified replacement

Trait Implementations

impl<'a, P, R> Display for ReplacedString<'a, P, R> where
    P: Pattern<'a> + Clone,
    R: Display
[src]

Auto Trait Implementations

impl<'a, P, R> Send for ReplacedString<'a, P, R> where
    P: Send,
    R: Send

impl<'a, P, R> Unpin for ReplacedString<'a, P, R> where
    P: Unpin,
    R: Unpin

impl<'a, P, R> Sync for ReplacedString<'a, P, R> where
    P: Sync,
    R: Sync

impl<'a, P, R> UnwindSafe for ReplacedString<'a, P, R> where
    P: UnwindSafe,
    R: UnwindSafe

impl<'a, P, R> RefUnwindSafe for ReplacedString<'a, P, R> where
    P: RefUnwindSafe,
    R: RefUnwindSafe

Blanket Implementations

impl<T> LazyReplaceDisplay for T where
    T: Display
[src]

fn replace_display<R>(Self, &'a str, R) -> ReplaceDisplay<'a, T, R>[src]

Create a struct implementing Display that will display this string with the specified pattern replaced with the specified replacement

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

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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.

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

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

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