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

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

§

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

§

type Item = u8

The type of the elements being iterated over.
§

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

§

type Item = &'a mut u8

The type of the elements being iterated over.
§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<RawStr> for RawStr

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PartialOrd<RawStr> 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

This method 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

§

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 StructuralEq for RawStr

source§

impl StructuralPartialEq for RawStr

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

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

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more