pub trait SensorExt: Sensor {
    fn map<ToObservations, F>(
        self,
        map_f: F
    ) -> MapSensor<Self, ToObservations, F>
    where
        Self: Sized,
        F: Fn(Self::Observations) -> ToObservations
, { ... } }
Expand description

A trait for convenience methods automatically implemented for all types that conform to Sensor.

Provided Methods

Maps the observations of the sensor using the given closure.

For example, if a sensor has observations of type Vec<u64>, then we can create a sensor with observations (Vec<u64>, u64), where the second element of the tuple is the sum of all observations:

use fuzzcheck::SensorExt;
let sensor = sensor.map(|observations| {
   let sum = observations.iter().sum::<u64>();
   (observations, sum)
});

Implementors