#[repr(transparent)]pub struct RawStr<'a>(pub &'a [u8]);
Expand description
A reference to a string which is believed to contain valid UTF-8 string data, but which has not yet been verified to contain UTF-8 data.
Tuple Fields§
§0: &'a [u8]
Implementations§
Source§impl<'a> RawStr<'a>
impl<'a> RawStr<'a>
Sourcepub fn to_str_lossy(&self) -> Cow<'a, str>
pub fn to_str_lossy(&self) -> Cow<'a, str>
Converts this value to a string.
If the string is valid UTF-8, then this returns a borrowed &str
reference. If the string
does invalid UTF-8 sequences, then this will allocate a new String
and convert the
character data to UTF-8, replacing invalid sequences with the Unicode replacement character.
Sourcepub fn to_str(&self) -> Option<&'a str>
pub fn to_str(&self) -> Option<&'a str>
Validates that the string contains valid UTF-8, and returns Some(s)
if so.
If the string contains invalid UTF-8 sequences, this returns None
.
Sourcepub fn from_bytes(bytes: &'a [u8]) -> Self
pub fn from_bytes(bytes: &'a [u8]) -> Self
Wraps a byte array as RawStr
.
Sourcepub fn eq_ignore_ascii_case(&self, other: RawStr<'_>) -> bool
pub fn eq_ignore_ascii_case(&self, other: RawStr<'_>) -> bool
Equivalent to str::eq_ignore_ascii_case
Trait Implementations§
Source§impl<'a> Ord for RawStr<'a>
impl<'a> Ord for RawStr<'a>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialOrd for RawStr<'a>
impl<'a> PartialOrd for RawStr<'a>
impl<'a> Copy for RawStr<'a>
impl<'a> Eq for RawStr<'a>
impl<'a> StructuralPartialEq for RawStr<'a>
Auto Trait Implementations§
impl<'a> Freeze for RawStr<'a>
impl<'a> RefUnwindSafe for RawStr<'a>
impl<'a> Send for RawStr<'a>
impl<'a> Sync for RawStr<'a>
impl<'a> Unpin for RawStr<'a>
impl<'a> UnwindSafe for RawStr<'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