Function sknife::collection::map [] [src]

pub fn map<F, A, B>(map_fn: F, vect: &mut [A]) -> Vec<B> where
    F: FnMut(A) -> B,
    A: Clone

Maps a vector/list based on a mapping function

Arguments

  • map_fn - A mapping function to apply to the list
  • vect - A vector to apply the map to

Example

use sknife::collection::map;
let mut list = vec![1, 2, 3];
let plus_one = |x| x + 1;
map(plus_one, list.as_mut_slice());
 

Result

vec![2, 3, 4];