[][src]Module smart_access::core_impls

Implementation of At for core datatypes.

The following traits are implemented:

  • At<usize, View=T> for [T]: simple indexing
  • At<range, View=[T]> for [T]: subslice (of fixed size)
  • At<(), View=T> for Option<T>: the only meaningful sort of access
  • At<(), View=R> for Result<R,E>: access to the Ok value

All implementations never panic: None is returned instead if the index doesn't make sense. If you want panicking behaviour simply add .unwrap() to your access:

This example panics
let mut foo = [0,1,2];

(&mut foo[..]).at(3).access(|x| { *x += 1; }).unwrap();

is the same as

This example panics
(&mut foo[..])[3].access(|x| { *x += 1; });