pub trait Utf8BufMut: Utf8Buf {
// Required methods
fn try_truncate(&mut self, new_len: usize) -> Result<(), Utf8Error>;
fn push(&mut self, ch: char);
fn push_str(&mut self, s: &str);
fn clear(&mut self);
}Expand description
Extension trait for mutable UTF-8 validated buffer types.
This trait provides common mutable operations for buffer types that can be modified while maintaining UTF-8 validity.
Required Methods§
Sourcefn try_truncate(&mut self, new_len: usize) -> Result<(), Utf8Error>
fn try_truncate(&mut self, new_len: usize) -> Result<(), Utf8Error>
Truncates at a UTF-8 character boundary.
A length at or beyond the current byte length is a no-op. On failure the buffer is unchanged.
Sourcefn push(&mut self, ch: char)
fn push(&mut self, ch: char)
Appends a character to the buffer.
§Examples
use smol_bytes::{Utf8BufMut, Utf8BytesMut};
let mut buf = Utf8BytesMut::new();
buf.push('a');
buf.push('b');
assert_eq!(buf.as_str(), "ab");Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Utf8BufMut for Utf8Buffer
impl Utf8BufMut for Utf8BytesMut
Available on crate features
alloc or std only.