Skip to main content

WritableStringExt

Trait WritableStringExt 

Source
pub trait WritableStringExt: Writable<Target = String> {
    // Provided methods
    fn push_str(&mut self, s: &str) { ... }
    fn push(&mut self, c: char) { ... }
    fn pop(&mut self) -> Option<char> { ... }
    fn insert_str(&mut self, idx: usize, s: &str) { ... }
    fn insert(&mut self, idx: usize, c: char) { ... }
    fn remove(&mut self, idx: usize) -> char { ... }
    fn replace_range(
        &mut self,
        range: impl RangeBounds<usize>,
        replace_with: &str,
    ) { ... }
    fn clear(&mut self) { ... }
    fn extend(&mut self, iter: impl IntoIterator<Item = char>) { ... }
    fn truncate(&mut self, len: usize) { ... }
    fn split_off(&mut self, at: usize) -> String { ... }
}
Available on crate feature prelude only.
Expand description

An extension trait for Writable<String> that provides some convenience methods.

Provided Methods§

Source

fn push_str(&mut self, s: &str)

Pushes a character to the end of the string.

Source

fn push(&mut self, c: char)

Pushes a character to the end of the string.

Source

fn pop(&mut self) -> Option<char>

Pops a character from the end of the string.

Source

fn insert_str(&mut self, idx: usize, s: &str)

Inserts a string at the given index.

Source

fn insert(&mut self, idx: usize, c: char)

Inserts a character at the given index.

Source

fn remove(&mut self, idx: usize) -> char

Remove a character at the given index

Source

fn replace_range(&mut self, range: impl RangeBounds<usize>, replace_with: &str)

Replace a range of the string with the given string.

Source

fn clear(&mut self)

Clears the string, removing all characters.

Source

fn extend(&mut self, iter: impl IntoIterator<Item = char>)

Extends the string with the given iterator of characters.

Source

fn truncate(&mut self, len: usize)

Truncates the string to the given length.

Source

fn split_off(&mut self, at: usize) -> String

Splits the string off at the given index, returning the tail as a new string.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<W> WritableStringExt for W
where W: Writable<Target = String>,