Struct 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

Source

pub fn from<S: AsRef<RawStr> + ?Sized>(s: &S) -> &Self

Source

pub fn from_bytes(bytes: &[u8]) -> &Self

Source

pub fn from_str(bytes: &str) -> &Self

Source

pub fn as_bytes(&self) -> &[u8]

Source

pub fn from_bytes_mut(bytes: &mut [u8]) -> &mut Self

Source

pub fn as_bytes_mut(&mut self) -> &mut [u8]

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn as_ptr(&self) -> *const u8

Source

pub fn first(&self) -> Option<u8>

Source

pub fn first_mut(&mut self) -> Option<&mut u8>

Source

pub fn last(&self) -> Option<u8>

Source

pub fn last_mut(&mut self) -> Option<&mut u8>

Source

pub fn split_first(&self) -> Option<(u8, &RawStr)>

Source

pub fn split_first_mut(&mut self) -> Option<(&mut u8, &mut RawStr)>

Source

pub fn split_last(&self) -> Option<(u8, &RawStr)>

Source

pub fn split_last_mut(&mut self) -> Option<(&mut u8, &mut RawStr)>

Source

pub fn split_at(&self, mid: usize) -> (&RawStr, &RawStr)

Source

pub fn split_at_mut(&mut self, mid: usize) -> (&mut RawStr, &mut RawStr)

Source

pub fn contains_byte(&self, x: u8) -> bool

Source

pub fn starts_with<T: AsRef<RawStr>>(&self, x: T) -> bool

Source

pub fn ends_with<T: AsRef<RawStr>>(&self, x: T) -> bool

Source

pub fn get<I: RawStrIndex>(&self, index: I) -> Option<&I::Output>

Source

pub fn get_mut<I: RawStrIndex>(&mut self, index: I) -> Option<&mut I::Output>

Source

pub unsafe fn get_unchecked<I: RawStrIndex>(&self, index: I) -> &I::Output

Source

pub unsafe fn get_unchecked_mut<I: RawStrIndex>( &mut self, index: I, ) -> &mut I::Output

Source

pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &RawStr

Source

pub unsafe fn slice_mut_unchecked( &mut self, begin: usize, end: usize, ) -> &mut RawStr

Source

pub fn bytes(&self) -> Cloned<Iter<'_, u8>>

Source

pub fn bytes_mut(&mut self) -> IterMut<'_, u8>

Source

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.

Source

pub fn to_str(&self) -> Result<&str, Utf8Error>

Source

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.

Source

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.

Source

pub fn is_ascii(&self) -> bool

Source

pub fn eq_ignore_ascii_case(&self, other: &RawStr) -> bool

Source

pub fn make_ascii_uppercase(&mut self)

Source

pub fn make_ascii_lowercase(&mut self)

Trait Implementations§

Source§

impl AsRef<[u8]> for RawStr

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<RawStr> for [u8]

Source§

fn as_ref(&self) -> &RawStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<RawStr> for RawStr

Source§

fn as_ref(&self) -> &RawStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<RawStr> for RawString

Source§

fn as_ref(&self) -> &RawStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<RawStr> for str

Source§

fn as_ref(&self) -> &RawStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<RawStr> for RawString

Source§

fn borrow(&self) -> &RawStr

Immutably borrows from an owned value. Read more
Source§

impl Debug for RawStr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for &'a RawStr

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a> Default for &'a mut RawStr

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for RawStr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a [u8]> for &'a RawStr

Source§

fn from(src: &'a [u8]) -> &'a RawStr

Converts to this type from the input type.
Source§

impl<'a> From<&'a RawStr> for RawString

Source§

fn from(src: &'a RawStr) -> RawString

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for &'a RawStr

Source§

fn from(src: &'a str) -> &'a RawStr

Converts to this type from the input type.
Source§

impl Hash for RawStr

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
Source§

impl<I: RawStrIndex> Index<I> for RawStr

Source§

type Output = <I as RawStrIndex>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &I::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<I: RawStrIndex> IndexMut<I> for RawStr

Source§

fn index_mut(&mut self, index: I) -> &mut I::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IntoIterator for &'a RawStr

Source§

type Item = u8

The type of the elements being iterated over.
Source§

type IntoIter = Cloned<Iter<'a, u8>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a mut RawStr

Source§

type Item = &'a mut u8

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, u8>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl Ord for RawStr

Source§

fn cmp(&self, other: &RawStr) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl PartialEq<&[u8]> for RawStr

Source§

fn eq(&self, other: &&[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&RawStr> for RawString

Source§

fn eq(&self, other: &&RawStr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&str> for RawStr

Source§

fn eq(&self, other: &&str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<[u8]> for RawStr

Source§

fn eq(&self, other: &[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<RawStr> for &[u8]

Source§

fn eq(&self, other: &RawStr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<RawStr> for &str

Source§

fn eq(&self, other: &RawStr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<RawStr> for [u8]

Source§

fn eq(&self, other: &RawStr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<RawStr> for RawString

Source§

fn eq(&self, other: &RawStr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<RawStr> for str

Source§

fn eq(&self, other: &RawStr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<RawString> for &RawStr

Source§

fn eq(&self, other: &RawString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<RawString> for RawStr

Source§

fn eq(&self, other: &RawString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for RawStr

Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for RawStr

Source§

fn eq(&self, other: &RawStr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd<&[u8]> for RawStr

Source§

fn partial_cmp(&self, other: &&[u8]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<&RawStr> for RawString

Source§

fn partial_cmp(&self, other: &&RawStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<&str> for RawStr

Source§

fn partial_cmp(&self, other: &&str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<[u8]> for RawStr

Source§

fn partial_cmp(&self, other: &[u8]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<RawStr> for &[u8]

Source§

fn partial_cmp(&self, other: &RawStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<RawStr> for &str

Source§

fn partial_cmp(&self, other: &RawStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<RawStr> for [u8]

Source§

fn partial_cmp(&self, other: &RawStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<RawStr> for RawString

Source§

fn partial_cmp(&self, other: &RawStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<RawStr> for str

Source§

fn partial_cmp(&self, other: &RawStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<RawString> for &RawStr

Source§

fn partial_cmp(&self, other: &RawString) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<RawString> for RawStr

Source§

fn partial_cmp(&self, other: &RawString) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<str> for RawStr

Source§

fn partial_cmp(&self, other: &str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for RawStr

Source§

fn partial_cmp(&self, other: &RawStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl RawStrExt for RawStr

Conversions only available on unix.

Source§

fn as_osstr(&self) -> &OsStr

Source§

fn as_path(&self) -> &Path

Source§

impl ToOwned for RawStr

Source§

type Owned = RawString

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> RawString

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl Eq for RawStr

Source§

impl StructuralPartialEq for RawStr

Auto Trait Implementations§

§

impl Freeze for RawStr

§

impl RefUnwindSafe for RawStr

§

impl Send for RawStr

§

impl !Sized for RawStr

§

impl Sync for RawStr

§

impl Unpin for RawStr

§

impl UnwindSafe for RawStr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more