macro_rules! impl_ops_for_memoryview {
($v:ident<$($a:lifetime,)? $($param:ident$(: $bound:path)?),*>) => { ... };
}Expand description
A helper macro for implementing std::ops::Index and
std::ops::IndexMut in terms of [View] and [ViewMut].
use multidimension::{Index, View, ViewRef, ViewMut, impl_ops_for_memoryview};
pub struct VecView<T: Clone>(Vec<T>);
impl<T: Clone> View for VecView<T> {
type I = usize;
type T = T;
fn size(&self) -> usize { self.0.len() }
fn at(&self, index: usize) -> T { self.0[index].clone() }
}
impl<T: Clone> ViewRef for VecView<T> {
fn at_ref(&self, index: Self::I) -> &Self::T { &self.0[index] }
}
impl<T: Clone> ViewMut for VecView<T> {
fn at_mut(&mut self, index: Self::I) -> &mut Self::T { &mut self.0[index] }
}
impl_ops_for_memoryview!(VecView<T: Clone>);