map_vec

Function map_vec 

Source
pub fn map_vec<I, O>(op: fn(I) -> O) -> impl Fn(Vec<I>) -> Vec<O>
Expand description

Convert all elements in the Vec to a new type.

#[derive(Debug, Valust)]
struct Map {
    #[trans(func(Vec<String> => map_vec(|x: String| x.trim().to_string())))]
    items: Vec<String>
}

let map = Raw::<Map> { items: vec![" 1 ".to_string(), "2".to_string()] };
let val = Map::validate(map);
assert_eq!(vec!["1".to_string(), "2".to_string()], val.unwrap().items);