Trait bitvec::slice::BitSliceIndex
source · [−]pub trait BitSliceIndex<'a, O, T> where
O: BitOrder,
T: BitStore, {
type Immut;
type Mut;
fn get(self, slice: &'a BitSlice<O, T>) -> Option<Self::Immut>;
fn get_mut(self, slice: &'a mut BitSlice<O, T>) -> Option<Self::Mut>;
unsafe fn get_unchecked(self, slice: &'a BitSlice<O, T>) -> Self::Immut;
unsafe fn get_unchecked_mut(
self,
slice: &'a mut BitSlice<O, T>
) -> Self::Mut;
fn index(self, slice: &'a BitSlice<O, T>) -> Self::Immut;
fn index_mut(self, slice: &'a mut BitSlice<O, T>) -> Self::Mut;
}
Expand description
A helper trait used for indexing operations.
This trait has its definition stabilized, but has not stabilized its associated
methods. This means it cannot be implemented outside of the distribution
libraries. Furthermore, since bitvec
cannot create &mut bool
references,
it is insufficient for bitvec
’s uses.
There is no tracking issue for feature(slice_index_methods)
.
Original
API Differences
SliceIndex::Output
is not usable here, because the usize
implementation
cannot produce &mut bool
. Instead, two output types Immut
and Mut
are
defined. The range implementations define these to be the appropriately mutable
BitSlice
reference; the usize
implementation defines them to be &bool
and the proxy type.
Associated Types
Required methods
Returns a mutable reference to the output at this location, if in bounds.
Original
unsafe fn get_unchecked(self, slice: &'a BitSlice<O, T>) -> Self::Immut
unsafe fn get_unchecked(self, slice: &'a BitSlice<O, T>) -> Self::Immut
Returns a shared reference to the output at this location, without performing any bounds checking. Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.
Original
Safety
As this function does not perform boundary checking, the caller must
ensure that self
is an index within the boundaries of slice
before
calling in order to prevent boundary escapes and the ensuing safety
violations.
unsafe fn get_unchecked_mut(self, slice: &'a mut BitSlice<O, T>) -> Self::Mut
unsafe fn get_unchecked_mut(self, slice: &'a mut BitSlice<O, T>) -> Self::Mut
Returns a mutable reference to the output at this location, without performing any bounds checking. Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.
Original
Safety
As this function does not perform boundary checking, the caller must
ensure that self
is an index within the boundaries of slice
before
calling in order to prevent boundary escapes and the ensuing safety
violations.
Returns a shared reference to the output at this location, panicking if out of bounds.
Original
Implementations on Foreign Types
sourceimpl<'a, O, T> BitSliceIndex<'a, O, T> for usize where
O: BitOrder,
T: BitStore,
impl<'a, O, T> BitSliceIndex<'a, O, T> for usize where
O: BitOrder,
T: BitStore,
type Immut = BitRef<'a, Const, O, T>
type Mut = BitRef<'a, Mut, O, T>
fn get(self, slice: &'a BitSlice<O, T>) -> Option<Self::Immut>
fn get_mut(self, slice: &'a mut BitSlice<O, T>) -> Option<Self::Mut>
unsafe fn get_unchecked(self, slice: &'a BitSlice<O, T>) -> Self::Immut
unsafe fn get_unchecked_mut(self, slice: &'a mut BitSlice<O, T>) -> Self::Mut
fn index(self, slice: &'a BitSlice<O, T>) -> Self::Immut
fn index_mut(self, slice: &'a mut BitSlice<O, T>) -> Self::Mut
sourceimpl<'a, O, T> BitSliceIndex<'a, O, T> for Range<usize> where
O: BitOrder,
T: BitStore,
impl<'a, O, T> BitSliceIndex<'a, O, T> for Range<usize> where
O: BitOrder,
T: BitStore,
type Immut = &'a BitSlice<O, T>
type Mut = &'a mut BitSlice<O, T>
fn get(self, slice: Self::Immut) -> Option<Self::Immut>
fn get_mut(self, slice: Self::Mut) -> Option<Self::Mut>
unsafe fn get_unchecked(self, slice: Self::Immut) -> Self::Immut
unsafe fn get_unchecked_mut(self, slice: Self::Mut) -> Self::Mut
fn index(self, slice: Self::Immut) -> Self::Immut
fn index_mut(self, slice: Self::Mut) -> Self::Mut
sourceimpl<'a, O, T> BitSliceIndex<'a, O, T> for RangeFrom<usize> where
O: BitOrder,
T: BitStore,
impl<'a, O, T> BitSliceIndex<'a, O, T> for RangeFrom<usize> where
O: BitOrder,
T: BitStore,
type Immut = &'a BitSlice<O, T>
type Mut = &'a mut BitSlice<O, T>
fn get(self, slice: Self::Immut) -> Option<Self::Immut>
fn get_mut(self, slice: Self::Mut) -> Option<Self::Mut>
unsafe fn get_unchecked(self, slice: Self::Immut) -> Self::Immut
unsafe fn get_unchecked_mut(self, slice: Self::Mut) -> Self::Mut
fn index(self, slice: Self::Immut) -> Self::Immut
fn index_mut(self, slice: Self::Mut) -> Self::Mut
sourceimpl<'a, O, T> BitSliceIndex<'a, O, T> for RangeTo<usize> where
O: BitOrder,
T: BitStore,
impl<'a, O, T> BitSliceIndex<'a, O, T> for RangeTo<usize> where
O: BitOrder,
T: BitStore,
type Immut = &'a BitSlice<O, T>
type Mut = &'a mut BitSlice<O, T>
fn get(self, slice: Self::Immut) -> Option<Self::Immut>
fn get_mut(self, slice: Self::Mut) -> Option<Self::Mut>
unsafe fn get_unchecked(self, slice: Self::Immut) -> Self::Immut
unsafe fn get_unchecked_mut(self, slice: Self::Mut) -> Self::Mut
fn index(self, slice: Self::Immut) -> Self::Immut
fn index_mut(self, slice: Self::Mut) -> Self::Mut
sourceimpl<'a, O, T> BitSliceIndex<'a, O, T> for RangeInclusive<usize> where
O: BitOrder,
T: BitStore,
impl<'a, O, T> BitSliceIndex<'a, O, T> for RangeInclusive<usize> where
O: BitOrder,
T: BitStore,
type Immut = &'a BitSlice<O, T>
type Mut = &'a mut BitSlice<O, T>
fn get(self, slice: Self::Immut) -> Option<Self::Immut>
fn get_mut(self, slice: Self::Mut) -> Option<Self::Mut>
unsafe fn get_unchecked(self, slice: Self::Immut) -> Self::Immut
unsafe fn get_unchecked_mut(self, slice: Self::Mut) -> Self::Mut
fn index(self, slice: Self::Immut) -> Self::Immut
fn index_mut(self, slice: Self::Mut) -> Self::Mut
sourceimpl<'a, O, T> BitSliceIndex<'a, O, T> for RangeToInclusive<usize> where
O: BitOrder,
T: BitStore,
impl<'a, O, T> BitSliceIndex<'a, O, T> for RangeToInclusive<usize> where
O: BitOrder,
T: BitStore,
type Immut = &'a BitSlice<O, T>
type Mut = &'a mut BitSlice<O, T>
fn get(self, slice: Self::Immut) -> Option<Self::Immut>
fn get_mut(self, slice: Self::Mut) -> Option<Self::Mut>
unsafe fn get_unchecked(self, slice: Self::Immut) -> Self::Immut
unsafe fn get_unchecked_mut(self, slice: Self::Mut) -> Self::Mut
fn index(self, slice: Self::Immut) -> Self::Immut
fn index_mut(self, slice: Self::Mut) -> Self::Mut
sourceimpl<'a, O, T> BitSliceIndex<'a, O, T> for RangeFull where
O: BitOrder,
T: BitStore,
impl<'a, O, T> BitSliceIndex<'a, O, T> for RangeFull where
O: BitOrder,
T: BitStore,
RangeFull
is the identity function.