Skip to main content

ReplaceText

Struct ReplaceText 

Source
pub struct ReplaceText<O: TextOut> { /* private fields */ }
Expand description

Replaces every occurrence of a fixed literal, across fragment boundaries.

The text is treated as one string however it is chunked, with the same left-to-right, non-overlapping matches as str::replace. To do that without holding the text, at most literal.len() - 1 bytes are carried from one fragment to the next: the longest suffix of what has been seen that could still begin a match. flush writes the carry out, because nothing can complete it once the caller has declared the text at a boundary; the renderer’s single flush at the end of a document is what makes that safe. An empty literal matches nothing and the text passes through unchanged, the one well-defined meaning it can have in a stream.

Implementations§

Source§

impl<O: TextOut> ReplaceText<O>

Source

pub fn new(out: O, from: impl Into<Box<str>>, to: impl Into<Box<str>>) -> Self

Source

pub fn into_inner(self) -> O

Trait Implementations§

Source§

impl<O: TextOut> TextOut for ReplaceText<O>

Source§

fn has_committed(&self) -> bool

The carry has not gone anywhere; only the output beneath knows.

Source§

fn write_str(&mut self, s: &str) -> Result<(), Fail>

Source§

fn flush(&mut self) -> Result<(), Fail>

Auto Trait Implementations§

§

impl<O> Freeze for ReplaceText<O>
where O: Freeze,

§

impl<O> RefUnwindSafe for ReplaceText<O>
where O: RefUnwindSafe,

§

impl<O> Send for ReplaceText<O>
where O: Send,

§

impl<O> Sync for ReplaceText<O>
where O: Sync,

§

impl<O> Unpin for ReplaceText<O>
where O: Unpin,

§

impl<O> UnsafeUnpin for ReplaceText<O>
where O: UnsafeUnpin,

§

impl<O> UnwindSafe for ReplaceText<O>
where O: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.