[−][src]Struct lazy_string_replace::ReplacedString
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
Auto Trait Implementations
impl<'a, P, R> Send for ReplacedString<'a, P, R> where
P: Send,
R: Send,
P: Send,
R: Send,
impl<'a, P, R> Unpin for ReplacedString<'a, P, R> where
P: Unpin,
R: Unpin,
P: Unpin,
R: Unpin,
impl<'a, P, R> Sync for ReplacedString<'a, P, R> where
P: Sync,
R: Sync,
P: Sync,
R: Sync,
impl<'a, P, R> UnwindSafe for ReplacedString<'a, P, R> where
P: UnwindSafe,
R: UnwindSafe,
P: UnwindSafe,
R: UnwindSafe,
impl<'a, P, R> RefUnwindSafe for ReplacedString<'a, P, R> where
P: RefUnwindSafe,
R: RefUnwindSafe,
P: RefUnwindSafe,
R: RefUnwindSafe,
Blanket Implementations
impl<T> LazyReplaceDisplay for T where
T: Display,
[src]
T: Display,
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]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,