pub trait Utf8BufMut: Utf8Buf + AsMut<str> {
type CapacityError: Error;
// Required methods
fn try_truncate(&mut self, new_len: usize) -> Result<(), Utf8IndexError>;
fn try_push(&mut self, ch: char) -> Result<(), Self::CapacityError>;
fn try_push_str(&mut self, s: &str) -> Result<(), Self::CapacityError>;
fn clear(&mut self);
// Provided methods
fn as_mut_str(&mut self) -> &mut str { ... }
fn push(&mut self, ch: char) { ... }
fn push_str(&mut self, s: &str) { ... }
}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 Associated Types§
Sourcetype CapacityError: Error
type CapacityError: Error
The error returned when an append cannot fit.
Required Methods§
Sourcefn try_truncate(&mut self, new_len: usize) -> Result<(), Utf8IndexError>
fn try_truncate(&mut self, new_len: usize) -> Result<(), Utf8IndexError>
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 try_push(&mut self, ch: char) -> Result<(), Self::CapacityError>
fn try_push(&mut self, ch: char) -> Result<(), Self::CapacityError>
Attempts to append a character.
Sourcefn try_push_str(&mut self, s: &str) -> Result<(), Self::CapacityError>
fn try_push_str(&mut self, s: &str) -> Result<(), Self::CapacityError>
Attempts to append a string slice.
Provided Methods§
Sourcefn as_mut_str(&mut self) -> &mut str
fn as_mut_str(&mut self) -> &mut str
Returns the contents as a mutable string slice.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl Utf8BufMut for Utf8Buffer
impl Utf8BufMut for Utf8Buffer
type CapacityError = TryPutError
Source§impl Utf8BufMut for Utf8BytesMut
Available on crate features alloc or std only.
impl Utf8BufMut for Utf8BytesMut
Available on crate features
alloc or std only.