impl_op_for_view

Macro impl_op_for_view 

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

Implement one of the std::ops traits for a type that implements View.

You perhaps want to use impl_ops_for_view instead, which calls this.

use multidimension::{Index, View, impl_op_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_op_for_view! { Add for VecView<T: Clone> { add } }
impl_op_for_view! { BitXor for VecView<T: Clone> { bitxor } }
// Etc.