pub struct FormattedBytes { /* private fields */ }Expand description
A stack-allocated buffer containing the formatted byte string.
FormattedBytes calculates the formatting upon instantiation and stores
the result internally. It can be cheaply converted to a &str or &[u8].
Implementations§
Source§impl FormattedBytes
impl FormattedBytes
Sourcepub fn as_bytes(&self) -> &[u8]
pub fn as_bytes(&self) -> &[u8]
Returns the formatted output as a raw byte slice.
Useful for direct std::io::Write usage.
Sourcepub fn as_str(&self) -> Result<&str, Utf8Error>
pub fn as_str(&self) -> Result<&str, Utf8Error>
Returns the formatted output as a UTF-8 string slice.
§Errors
Returns a core::str::Utf8Error if the internal buffer contains
invalid UTF-8 bytes. (Note: The format method only writes valid
ASCII characters, so this is guaranteed to succeed in practice).
Trait Implementations§
Source§impl Clone for FormattedBytes
impl Clone for FormattedBytes
Source§fn clone(&self) -> FormattedBytes
fn clone(&self) -> FormattedBytes
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Display for FormattedBytes
Allows FormattedBytes to be used in standard Rust formatting macros
(e.g., format!(), println!(), write!()).
impl Display for FormattedBytes
Allows FormattedBytes to be used in standard Rust formatting macros
(e.g., format!(), println!(), write!()).
impl Copy for FormattedBytes
Auto Trait Implementations§
impl Freeze for FormattedBytes
impl RefUnwindSafe for FormattedBytes
impl Send for FormattedBytes
impl Sync for FormattedBytes
impl Unpin for FormattedBytes
impl UnsafeUnpin for FormattedBytes
impl UnwindSafe for FormattedBytes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more