Macro index_fixed::index_fixed_get [] [src]

macro_rules! index_fixed_get {
    (&mut $s:expr ;  .. $e:expr) => { ... };
    (&mut $s:expr ; $b:expr , ... $e:expr) => { ... };
    (&mut $s:expr ; $b:expr , .. $e:expr) => { ... };
    (& $s:expr ; .. $e:expr) => { ... };
    (& $s:expr ; $b:expr , ... $e:expr) => { ... };
    (& $s:expr ; $b:expr , .. $e:expr) => { ... };
}

slice::get and slice::get_mut, but return an Option<&[T;N]> or Option<&mut [T;N]>

Will not compile if bounds are not static.

Will not compile if end bound proceeds start bound.

Format

index_fixed_get! ( {&,&mut} <slice> ; .. <end>)
index_fixed_get! ( {&,&mut} <slice> ; <start> , .. <end>)
index_fixed_get! ( {&,&mut} <slice> ; <start> , ... <end>)

Examples

#[macro_use]
extern crate index_fixed;

fn main() {
  let my_slice = [1, 2, 3, 4];
  let slice_of_2 = index_fixed_get!(&my_slice ; .. 2);
  assert_eq!(slice_of_2, Some(&[1,2]));
}