pub trait SliceIndex: Sealed {
type Output: ?Sized;
// Required methods
fn get(self, slice: &BStr) -> Option<&Self::Output>;
fn get_mut(self, slice: &mut BStr) -> Option<&mut Self::Output>;
unsafe fn get_unchecked(self, slice: &BStr) -> &Self::Output;
unsafe fn get_unchecked_mut(self, slice: &mut BStr) -> &mut Self::Output;
fn index(self, slice: &BStr) -> &Self::Output;
fn index_mut(self, slice: &mut BStr) -> &mut Self::Output;
}
Expand description
A trait that parameterizes the different types of indexing a byte string.
In general, this trait makes it possible to define generic routines like
get
that can accept either single positions or ranges, and return single
bytes or slices, respectively.
This trait is sealed such that callers cannot implement it. In general, callers should not need to interact with this trait directly unless you’re defining generic functions that index or slice a byte string.
Required Associated Types§
Required Methods§
Sourcefn get(self, slice: &BStr) -> Option<&Self::Output>
fn get(self, slice: &BStr) -> Option<&Self::Output>
Returns a shared reference to the output at this location, if in bounds.
Sourcefn get_mut(self, slice: &mut BStr) -> Option<&mut Self::Output>
fn get_mut(self, slice: &mut BStr) -> Option<&mut Self::Output>
Returns a mutable reference to the output at this location, if in bounds.
Sourceunsafe fn get_unchecked(self, slice: &BStr) -> &Self::Output
unsafe fn get_unchecked(self, slice: &BStr) -> &Self::Output
Returns a shared reference to the output at this location, without performing any bounds checking.
Sourceunsafe fn get_unchecked_mut(self, slice: &mut BStr) -> &mut Self::Output
unsafe fn get_unchecked_mut(self, slice: &mut BStr) -> &mut Self::Output
Returns a mutable reference to the output at this location, without performing any bounds checking.