impl_ops_for_view

Macro impl_ops_for_view 

Source
macro_rules! impl_ops_for_view {
    ($v:ident<$($a:lifetime,)? $($param:ident$(: $bound:path)?),*>) => { ... };
}
Expand description

Implement all of the std::ops traits for a type that implements View. The implementations call View::binary().

The macro has some syntactic limitations, but should usually work.

use multidimension::{Index, View, impl_ops_for_view};

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_ops_for_view!(VecView<T: Clone>);