arrayref::mut_array_refs! [] [src]

macro_rules! mut_array_refs {
    ( $arr:expr, $( $len:expr ),* ) => {{
        {
            #[inline]
            #[allow(unused_assignments)]
            unsafe fn as_arrays<T>(a: &mut[T; $( $len + )* 0 ]
                                   ) -> ( $( &mut[T; $len], )* ) {
                let mut p = a.as_ptr() as *mut T;
                ( $( {
                    let aref = &mut *(p as *mut [T; $len]);
                    p = p.offset($len);
                    aref
                } ),* )
            }
            let input = $arr;
            unsafe {
                as_arrays(input)
            }
        }
    }}
}

You can use mut_array_refs to generate a series of mutable array references to an input mutable array reference. The idea is if you want to break an array into a series of contiguous and non-overlapping arrays.