Trait otter_api_tests::imports::vecdeque_stableix::Offset [−]
pub trait Offset: Clone + Debug + Neg + PartialEq<Self> + Eq { pub fn try_increment(&mut self) -> Option<()>; pub fn try_decrement(&mut self) -> Option<()>; pub fn zero() -> Self; pub fn index_input(&self, input: Self) -> Option<usize>; pub fn index_output(&self, inner: usize) -> Option<Self>; }
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
pub 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.
pub 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.
pub fn zero() -> Self
pub 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.
pub 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 Offset for UpdateId
[src]
pub fn try_increment(&mut self) -> Option<()>
[src]
pub fn try_decrement(&mut self) -> Option<()>
[src]
pub fn index_input(&self, input: UpdateId) -> Option<usize>
[src]
pub fn index_output(&self, inner: usize) -> Option<UpdateId>
[src]
pub fn zero() -> UpdateId
[src]
impl<T> Offset for T where
T: Clone + Debug + Neg + PartialEq<T> + Eq + Zero + One + CheckedAdd + CheckedSub + TryInto<usize> + TryFrom<usize>,
T: Clone + Debug + Neg + PartialEq<T> + Eq + Zero + One + CheckedAdd + CheckedSub + TryInto<usize> + TryFrom<usize>,