pub struct Lossy<'a>(pub &'a [u8]);Expand description
Displays bytes that may not be valid UTF-8, without allocating.
Valid UTF-8 sequences are written as they are and every byte of an invalid sequence is written
as a \xNN escape, e.g. caf\xE9 for the Latin-1 encoding of café. It is used by the
Display implementation of Error::InvalidUtf8.
use getargs_derive::Lossy;
assert_eq!(Lossy(b"caf\xE9.txt").to_string(), "caf\\xE9.txt");
assert_eq!(Lossy("café".as_bytes()).to_string(), "café");Tuple Fields§
§0: &'a [u8]Trait Implementations§
impl<'a> Copy for Lossy<'a>
impl<'a> Eq for Lossy<'a>
impl<'a> StructuralPartialEq for Lossy<'a>
Auto Trait Implementations§
impl<'a> Freeze for Lossy<'a>
impl<'a> RefUnwindSafe for Lossy<'a>
impl<'a> Send for Lossy<'a>
impl<'a> Sync for Lossy<'a>
impl<'a> Unpin for Lossy<'a>
impl<'a> UnsafeUnpin for Lossy<'a>
impl<'a> UnwindSafe for Lossy<'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