Skip to main content

AnyString

Trait AnyString 

Source
pub trait AnyString {
    // Required methods
    fn as_str(&self) -> &str;
    fn len(&self) -> usize;
    fn push_str(&mut self, s: &str);
    fn push(&mut self, ch: char);
    fn clear(&mut self);
    fn pop(&mut self) -> Option<char>;
    fn truncate(&mut self, new_len: usize);

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A trait for abstraction over different string types (Stack, Heap, Small).

Required Methods§

Source

fn as_str(&self) -> &str

Returns a string slice representing the contents.

Source

fn len(&self) -> usize

Returns the number of elements.

Source

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

Pushes an item into the collection.

Source

fn push(&mut self, ch: char)

Pushes an item into the collection.

Source

fn clear(&mut self)

Clears all elements from the collection.

Source

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

Removes and returns an item from the collection.

Source

fn truncate(&mut self, new_len: usize)

Truncates the collection to a specific length.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if the collection is empty.

Implementations on Foreign Types§

Source§

impl AnyString for String

Source§

fn as_str(&self) -> &str

Source§

fn len(&self) -> usize

Source§

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

Source§

fn push(&mut self, ch: char)

Source§

fn clear(&mut self)

Source§

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

Source§

fn truncate(&mut self, new_len: usize)

Implementors§

Source§

impl<const N: usize> AnyString for SmallString<N>