pub trait HasTotalReverseGet<S, A> {
// Required method
fn reverse_get(&self, value: &A) -> S;
}Expand description
Provides a simplified interface for optics with infallible reverse-get operations.
This trait is automatically implemented for any optic that implements
HasReverseGet with a ReverseError type of Infallible and
[HasGetter] with a [GetterError] type of Infallible
§Example
use optics::{HasTotalReverseGet, mapped_iso};
#[derive(PartialEq, Debug)]
struct Point {
x: u16,
y: u16,
}
let point_iso = mapped_iso(
|p: &Point| (p.x as u32) << 16 + p.y as u32,
|v| Point { x: (v / (1<<16)) as u16 , y: (v % (1<<16)) as u16 },
);
let point = point_iso.reverse_get(&10);
assert_eq!(point, Point { x: 0, y: 10 });