pub trait WrappingGet<T> {
    // Required methods
    fn wrapping_next(&self, idx: usize) -> &T;
    fn wrapping_prev(&self, idx: usize) -> &T;
}
Expand description

Read next or previous, wrapping if we go out of bounds.

This is particularly useful when porting from Python where reading idx - 1, with -1 meaning last, is common.

Required Methods§

source

fn wrapping_next(&self, idx: usize) -> &T

source

fn wrapping_prev(&self, idx: usize) -> &T

Implementations on Foreign Types§

source§

impl<T> WrappingGet<T> for &[T]

source§

fn wrapping_next(&self, idx: usize) -> &T

source§

fn wrapping_prev(&self, idx: usize) -> &T

Implementors§