pub trait Iso: Sized {
    type Real: Clone + From<Self>;

    fn test(x: &Self::Real) -> Self;
    fn real(&self) -> Self::Real;
}
Expand description

Trait that declares the relationship between a “test” and “real struct”, namely how to go back and forth between the two.

Required Associated Types

The real data which corresponds to the type this trait is defined for

Required Methods

Return the test version of this data, mapping if necessary.

The test data must be a subset of the real data, so that this transformation is never lossy.

Return the real version of this data, mapping if necessary.

In general, the real data is a superset of the test data, so some arbitrary data will need to be supplied to fill in the rest. In fact, it is best if truly random arbitrary data is used, as this will act as a fuzz test of your trait implementation.

Implementors