Struct raw_string::RawStr
source · pub struct RawStr { /* private fields */ }
Expand description
A str
with unchecked contents.
It is basically a [u8]
, to be interpreted as string.
Unlike str
, there are no guarantees about the contents being valid UTF-8.
Unlike [u8]
, its Display and Debug implementations show a string, not an
array of numbers.
Implementations§
source§impl RawStr
impl RawStr
pub fn from<S: AsRef<RawStr> + ?Sized>(s: &S) -> &Self
pub fn from_bytes(bytes: &[u8]) -> &Self
pub fn from_str(bytes: &str) -> &Self
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn from_bytes_mut(bytes: &mut [u8]) -> &mut Self
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn as_ptr(&self) -> *const u8
pub fn first(&self) -> Option<u8>
pub fn first_mut(&mut self) -> Option<&mut u8>
pub fn last(&self) -> Option<u8>
pub fn last_mut(&mut self) -> Option<&mut u8>
pub fn split_first(&self) -> Option<(u8, &RawStr)>
pub fn split_first_mut(&mut self) -> Option<(&mut u8, &mut RawStr)>
pub fn split_last(&self) -> Option<(u8, &RawStr)>
pub fn split_last_mut(&mut self) -> Option<(&mut u8, &mut RawStr)>
pub fn split_at(&self, mid: usize) -> (&RawStr, &RawStr)
pub fn split_at_mut(&mut self, mid: usize) -> (&mut RawStr, &mut RawStr)
pub fn contains_byte(&self, x: u8) -> bool
pub fn starts_with<T: AsRef<RawStr>>(&self, x: T) -> bool
pub fn ends_with<T: AsRef<RawStr>>(&self, x: T) -> bool
pub fn get<I: RawStrIndex>(&self, index: I) -> Option<&I::Output>
pub fn get_mut<I: RawStrIndex>(&mut self, index: I) -> Option<&mut I::Output>
pub unsafe fn get_unchecked<I: RawStrIndex>(&self, index: I) -> &I::Output
pub unsafe fn get_unchecked_mut<I: RawStrIndex>( &mut self, index: I ) -> &mut I::Output
pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &RawStr
pub unsafe fn slice_mut_unchecked( &mut self, begin: usize, end: usize ) -> &mut RawStr
pub fn bytes(&self) -> Cloned<Iter<'_, u8>>
pub fn bytes_mut(&mut self) -> IterMut<'_, u8>
sourcepub fn utf8_chunks(&self) -> Utf8ChunksIter<'_> ⓘ
pub fn utf8_chunks(&self) -> Utf8ChunksIter<'_> ⓘ
Iterate over chunks of valid UTF-8.
The iterator iterates over the chunks of valid UTF-8 separated by any broken characters, which could be replaced by the unicode replacement character.
pub fn to_str(&self) -> Result<&str, Utf8Error>
sourcepub fn to_osstr(&self) -> Result<&OsStr, Utf8Error>
pub fn to_osstr(&self) -> Result<&OsStr, Utf8Error>
Convert to an OsStr.
On Unix, it never fails. On other platforms, it must be encoded as UTF-8.
A never-failing version for Unix only is available as
unix::RawStrExt::as_osstr
.
sourcepub fn to_path(&self) -> Result<&Path, Utf8Error>
pub fn to_path(&self) -> Result<&Path, Utf8Error>
Convert to a Path.
On Unix, it never fails. On other platforms, it must be encoded as UTF-8.
A never-failing version for Unix only is available as
unix::RawStrExt::as_path
.
pub fn is_ascii(&self) -> bool
pub fn eq_ignore_ascii_case(&self, other: &RawStr) -> bool
pub fn make_ascii_uppercase(&mut self)
pub fn make_ascii_lowercase(&mut self)
Trait Implementations§
source§impl<I: RawStrIndex> Index<I> for RawStr
impl<I: RawStrIndex> Index<I> for RawStr
source§impl<I: RawStrIndex> IndexMut<I> for RawStr
impl<I: RawStrIndex> IndexMut<I> for RawStr
source§impl<'a> IntoIterator for &'a RawStr
impl<'a> IntoIterator for &'a RawStr
source§impl<'a> IntoIterator for &'a mut RawStr
impl<'a> IntoIterator for &'a mut RawStr
source§impl PartialEq<&[u8]> for RawStr
impl PartialEq<&[u8]> for RawStr
source§impl PartialEq<&RawStr> for RawString
impl PartialEq<&RawStr> for RawString
source§impl PartialEq<&str> for RawStr
impl PartialEq<&str> for RawStr
source§impl PartialEq<[u8]> for RawStr
impl PartialEq<[u8]> for RawStr
source§impl PartialEq<RawStr> for &[u8]
impl PartialEq<RawStr> for &[u8]
source§impl PartialEq<RawStr> for &str
impl PartialEq<RawStr> for &str
source§impl PartialEq<RawStr> for [u8]
impl PartialEq<RawStr> for [u8]
source§impl PartialEq<RawStr> for RawStr
impl PartialEq<RawStr> for RawStr
source§impl PartialEq<RawStr> for RawString
impl PartialEq<RawStr> for RawString
source§impl PartialEq<RawStr> for str
impl PartialEq<RawStr> for str
source§impl PartialEq<RawString> for &RawStr
impl PartialEq<RawString> for &RawStr
source§impl PartialEq<RawString> for RawStr
impl PartialEq<RawString> for RawStr
source§impl PartialOrd<&[u8]> for RawStr
impl PartialOrd<&[u8]> for RawStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<&RawStr> for RawString
impl PartialOrd<&RawStr> for RawString
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<&str> for RawStr
impl PartialOrd<&str> for RawStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<[u8]> for RawStr
impl PartialOrd<[u8]> for RawStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawStr> for &[u8]
impl PartialOrd<RawStr> for &[u8]
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawStr> for &str
impl PartialOrd<RawStr> for &str
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawStr> for [u8]
impl PartialOrd<RawStr> for [u8]
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawStr> for RawStr
impl PartialOrd<RawStr> for RawStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawStr> for RawString
impl PartialOrd<RawStr> for RawString
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawStr> for str
impl PartialOrd<RawStr> for str
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawString> for &RawStr
impl PartialOrd<RawString> for &RawStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawString> for RawStr
impl PartialOrd<RawString> for RawStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<str> for RawStr
impl PartialOrd<str> for RawStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more