pub struct Replace<A, B, C> {
pub source: A,
pub needle: B,
pub replacement: C,
}Expand description
A Writeable adapter that replaces occurrences of a needle with a replacement.
This adapter performs the replacement in a streaming fashion during write_to,
requiring zero allocations.
§Examples
use writeable::adapters::Replace;
use writeable::assert_writeable_eq;
use writeable::concat_writeable;
let source = concat_writeable!("I 💖 🦀", " and 🦀 loves me!");
let replace = Replace {
source,
needle: "🦀",
replacement: "Rust",
};
assert_writeable_eq!(replace, "I 💖 Rust and Rust loves me!");Fields§
§source: AThe source writeable.
needle: BThe needle to search for.
replacement: CThe replacement writeable.
Trait Implementations§
Source§impl<'a, A: Writeable, C: Writeable> Display for Replace<A, &'a str, C>
This trait is implemented for compatibility with fmt!.
To create a string, [Writeable::write_to_string] is usually more efficient.
impl<'a, A: Writeable, C: Writeable> Display for Replace<A, &'a str, C>
This trait is implemented for compatibility with fmt!.
To create a string, [Writeable::write_to_string] is usually more efficient.
Source§impl<A, C> Writeable for Replace<A, &str, C>
impl<A, C> Writeable for Replace<A, &str, C>
Source§fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
Writes a string to the given sink. Errors from the sink are bubbled up.
The default implementation delegates to
write_to_parts, and discards any
Part annotations.Source§fn writeable_length_hint(&self) -> LengthHint
fn writeable_length_hint(&self) -> LengthHint
Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more
Source§fn write_to_parts<S: PartsWrite + ?Sized>(&self, sink: &mut S) -> Result
fn write_to_parts<S: PartsWrite + ?Sized>(&self, sink: &mut S) -> Result
Write bytes and
Part annotations to the given sink. Errors from the
sink are bubbled up. The default implementation delegates to write_to,
and doesn’t produce any Part annotations.Auto Trait Implementations§
impl<A, B, C> Freeze for Replace<A, B, C>
impl<A, B, C> RefUnwindSafe for Replace<A, B, C>
impl<A, B, C> Send for Replace<A, B, C>
impl<A, B, C> Sync for Replace<A, B, C>
impl<A, B, C> Unpin for Replace<A, B, C>
impl<A, B, C> UnsafeUnpin for Replace<A, B, C>
impl<A, B, C> UnwindSafe for Replace<A, B, C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more