[−][src]Trait vecdeque_stableix::Offset
Types that can be used as an index for a Deque.
The (fallible) operations required are a very limited subset of
arithmetic, combined with conversion between Offset
and usize
.
The provided generic implementation covers isize
, i64
, etc.
Required methods
fn try_increment(&mut self) -> Option<()>
Should return None
on overflow.
Currently, this will cause the library to panic,
but that may not always be the case.
fn try_decrement(&mut self) -> Option<()>
Should return None
on overflow.
Currently, this will cause the library to panic,
but that may not always be the case.
fn zero() -> Self
fn index_input(&self, input: Self) -> Option<usize>
Should return Some(input - self)
, or None
on overflow.
Overflows can easily happen with a very old index, if the index
type is bigger than usize
; this is handled gracefully by the
library.
So index_input
must not panic on overflow.
fn index_output(&self, inner: usize) -> Option<Self>
Should return Some(output + self)
.
Should return None
on overflow;
Currently, this will cause the library to panic,
but that may not always be the case.
Implementors
impl<T> Offset for T where
T: Clone + Debug + Neg + PartialEq + Eq + Zero + One + CheckedAdd + CheckedSub + TryInto<usize> + TryFrom<usize>,
[src]
T: Clone + Debug + Neg + PartialEq + Eq + Zero + One + CheckedAdd + CheckedSub + TryInto<usize> + TryFrom<usize>,