pub trait RawStrIndex {
type Output: ?Sized;
// Required methods
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 implementsRawStrIndex<Output=RawStr>, and - a
SliceIndex<[u8], Output=u8>automatically implementsRawStrIndex<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§
Required Methods§
Sourcefn get(self, s: &RawStr) -> Option<&Self::Output>
fn get(self, s: &RawStr) -> Option<&Self::Output>
Get the range or byte from the given &RawStr.
Sourcefn get_mut(self, s: &mut RawStr) -> Option<&mut Self::Output>
fn get_mut(self, s: &mut RawStr) -> Option<&mut Self::Output>
Get the (mutable) range or byte from the given &mut RawStr.
Sourceunsafe fn get_unchecked(self, s: &RawStr) -> &Self::Output
unsafe fn get_unchecked(self, s: &RawStr) -> &Self::Output
Like get, but unsafe and unchecked.
Sourceunsafe fn get_unchecked_mut(self, s: &mut RawStr) -> &mut Self::Output
unsafe fn get_unchecked_mut(self, s: &mut RawStr) -> &mut Self::Output
Like get_mut, but unsafe and unchecked.