Trait cooks::Cookable
[-]
[+]
[src]
pub trait Cookable<Rxty, F> { type Input; type Output; fn cook(self, f: F) -> Self::Output; fn cook_n(self, count: usize, f: F) -> Self::Output; }
Associated Types
Required Methods
fn cook(self, f: F) -> Self::Output
Example:
use cooks::Cookable; let vec = vec![1i32, 2, 3, 4]; let result = vec![Some(1f32), Some(2f32), Some(3f32), Some(4f32)]; assert_eq!(vec.cook(|&: x: i32| Some(x as f32)), result);
Example with failing cooks:
use cooks::Cookable; let vec = vec![1i32, 2, 3, 4]; let result = vec![Some(1f32), Some(2f32), None, Some(4f32)]; assert_eq!(vec.cook(|&: x: i32| { if x == 3 { panic!("Does not cook") } Some(x as f32) }), result);