pub struct PrettyBytes<'a>(pub &'a [u8]);Expand description
Helper struct that wraps a byte slice and improves its std::fmt::Debug formatting.
Printable ASCII characters are rendered as-is; non-printable bytes are escaped as \xNN.
Matches the formatting convention of the bytes::Bytes type for consistency across logs.
§Examples
assert_eq!(format!("{:?}", PrettyBytes(b"key1")), "b\"key1\"");
assert_eq!(format!("{:?}", PrettyBytes(b"\x00\xFF")), "b\"\\x00\\xff\"");Tuple Fields§
§0: &'a [u8]Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for PrettyBytes<'a>
impl<'a> RefUnwindSafe for PrettyBytes<'a>
impl<'a> Send for PrettyBytes<'a>
impl<'a> Sync for PrettyBytes<'a>
impl<'a> Unpin for PrettyBytes<'a>
impl<'a> UnsafeUnpin for PrettyBytes<'a>
impl<'a> UnwindSafe for PrettyBytes<'a>
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