pub trait StableIndexOffset: Clone + Debug + Neg + PartialEq<Self> + Eq {
    fn try_increment(&mut self) -> Option<()>;
    fn try_decrement(&mut self) -> Option<()>;
    fn zero() -> Self;
    fn index_input(&self, input: Self) -> Option<usize>;
    fn index_output(&self, inner: usize) -> Option<Self>;
}
Expand description

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

Should return None on overflow. Currently, this will cause the library to panic, but that may not always be the case.

Should return None on overflow. Currently, this will cause the library to panic, but that may not always be the case.

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.

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