[][src]Macro vec_dimension_shift::make_vec_dimension_shift_n_dimension

macro_rules! make_vec_dimension_shift_n_dimension {
    (
  $trait_symbol:ident,
  $trait_flatten_symbol:ident,
  $as_nc:ident,
  $to_nc:ident,
  $as_c:ident,
  $to_c:ident,
  $as_truncate:ident,
  $to_truncate:ident,
  $as_padding:ident,
  $to_padding:ident,
  $dimension:expr
 ) => { ... };
}

This is the trait generator. If you need the N-dimension version, then use it. (Note: 2D, 3D, 4D are available on the features. )

Usage

Code:

This example is not tested
make_vec_dimension_shift_n_dimension! { VecDimensionShift2D, VecDimensionShift2DFlatten, as_2d_array_no_check, to_2d_array_no_check, as_2d_array, to_2d_array, as_2d_array_truncate, to_2d_array_truncate, as_2d_array_padding, to_2d_array_padding, 2 }

Then you will get the VecDimensionShift2D trait. Thus, you can use the dimension shift implements such as:

This example is not tested
let my_vec = vec![0,1,2,3,4,5];
println!("my_vec is: {}", my_vec);
let my_2d_shifted = my_vec.as_2d_array().unwrap();
println!("my_2d_view is: {}", my_2d_view);
let my_flatten = my_2d_shifted.as_flatten();
println!("my_flatten is: {}", my_flatten);
let my_3d_view = my_flatten.as_3d_array().unwrap();
println!("my_3d_view is: {}", my_3d_view);

It can be simplify if the #![feature(concat_idents)] to stable, maybe.