pub trait RawStrIndex {
    type Output: ?Sized;

    fn get(self, s: &RawStr) -> Option<&Self::Output>;
    fn get_mut(self, s: &mut RawStr) -> Option<&mut Self::Output>;
    unsafe fn get_unchecked(self, s: &RawStr) -> &Self::Output;
    unsafe fn get_unchecked_mut(self, s: &mut RawStr) -> &mut Self::Output;
    fn index(self, s: &RawStr) -> &Self::Output;
    fn index_mut(self, s: &mut RawStr) -> &mut Self::Output;
}
Expand description

The equivalent of SliceIndex for RawStr.

Usage

Normally, this trait is not used directly. Its functionality is exposed through Index and the get methods of RawStr.

Implementors

RawStrIndex is automatically implemented for all that implement SliceIndex<[u8]>:

  • a SliceIndex<[u8], Output=[u8]> automatically implements RawStrIndex<Output=RawStr>, and
  • a SliceIndex<[u8], Output=u8> automatically implements RawStrIndex<Output=u8>.

Examples

let s = RawStr::from_str("hello world");
let hello: &RawStr = &s[..5]; // This is a slice.
let space: u8 = s[5]; // This is a single byte
assert_eq!(hello, "hello");
assert_eq!(space, b' ');

Required Associated Types

RawStr (for ranges) or u8 (for single indexes).

Required Methods

Get the range or byte from the given &RawStr.

Get the (mutable) range or byte from the given &mut RawStr.

Like get, but unsafe and unchecked.

Like get_mut, but unsafe and unchecked.

Like get, but panics on failure.

Like get_mut, but panics on failure.

Implementors