pub trait BitSliceIndex<'a, O, T> where
    O: 'a + BitOrder,
    T: 'a + 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

Replacement for slice::SliceIndex.

This trait is stabilized in definition and type Output only, but all methods are unstable. This makes it unusable in non-libstd slice libraries, and so it must be duplicated here.

There is no tracking issue for feature(slice_index_methods).

Associated Types

Immutable output type.

Mutable output type. This is necessary because &mut BitSlice is producible for range indices, but &mut bool is not producable for usize indices.

Required methods

Returns a shared reference to the output at this location, if in bounds.

Parameters
  • self: The index value.
  • slice: The slice under index.
Returns

An immutable output, if self is in bounds; otherwise None.

Returns a mutable reference to the output at this location, if in bounds.

Parameters
  • self: The index value.
  • slice: The slice under index.
Returns

A mutable output, if self is in bounds; otherwise None.

Returns a shared reference to the output at this location, without performing any bounds checking.

Parameters
  • self: The index value.
  • slice: The slice under index.
Returns

An immutable output.

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 avoid boundary escapes and ensuing safety violations.

Returns a mutable reference to the output at this location, without performing any bounds checking.

Parameters
  • self: The index value.
  • slice: The slice under index.
Returns

A mutable output.

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 avoid boundary escapes and ensuing safety violations.

Returns a shared reference to the output at this location, panicking if out of bounds.

Parameters
  • self: The index value.
  • slice: The slice under index.
Returns

An immutable output.

Panics

This panics if self is out of bounds of slice.

Returns a mutable reference to the output at this location, panicking if out of bounds.

Parameters
  • self: The index value.
  • slice: The slice under index.
Returns

A mutable output.

Panics

This panics if self is out of bounds of slice.

Implementations on Foreign Types

RangeFull is the identity function.

Implementors