Peep

Trait Peep 

Source
pub trait Peep: Sized {
    // Provided methods
    fn peep<F, R>(self, run: F) -> Self
       where F: FnOnce(&Self) -> R,
             R: Sized { ... }
    fn peep_dbg<F, R>(self, run: F) -> Self
       where F: FnOnce(&Self) -> R,
             R: Sized { ... }
    fn peep_mut<F, R>(self, run: F) -> Self
       where F: FnOnce(&mut Self) -> R,
             R: Sized { ... }
    fn peep_mut_dbg<F, R>(self, run: F) -> Self
       where F: FnOnce(&mut Self) -> R,
             R: Sized { ... }
}
Expand description

This trait allows for ‘peeping’ at values in chained function calls.

use fenn::Peep;

let vec = vec![1, 2, 3]
    .into_iter()
    .map(|i| i * 2)
    .peep(|vec| {
        // This is only for the assert and isn't normally needed
        let temp_vec: Vec<_> = vec.clone().collect();

         assert_eq!(temp_vec, [2, 4, 6]);
     })
    .map(|i| i / 2)
    .peep(|vec| {
        // Again this is only for the assert
        let temp_vec: Vec<_> = vec.clone().collect();

         assert_eq!(temp_vec, [1, 2, 3]);
     })
    .collect::<Vec<usize>>();

Provided Methods§

Source

fn peep<F, R>(self, run: F) -> Self
where F: FnOnce(&Self) -> R, R: Sized,

Source

fn peep_dbg<F, R>(self, run: F) -> Self
where F: FnOnce(&Self) -> R, R: Sized,

Source

fn peep_mut<F, R>(self, run: F) -> Self
where F: FnOnce(&mut Self) -> R, R: Sized,

Source

fn peep_mut_dbg<F, R>(self, run: F) -> Self
where F: FnOnce(&mut Self) -> R, R: Sized,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Sized> Peep for T