Trait stry_common::utils::Peep[][src]

pub trait Peep: Sized {
    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
, { ... } }

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

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

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

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

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

Loading content...

Implementors

impl<T: Sized> Peep for T[src]

Loading content...