1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use crateHasGetter;
use Infallible;
/// Provides a simplified interface for optics with infallible getter operations.
///
/// This trait is automatically implemented for any optic that implements
/// [`HasGetter`] with a [`GetterError`] type of [`Infallible`].
///
/// # Example
///
/// ```rust
/// use optics::{HasTotalGetter, mapped_getter};
///
/// struct Point {
/// x: u32,
/// y: u32,
/// }
///
/// let x_getter = mapped_getter(
/// |p: &Point| p.x,
/// );
///
/// let point = Point { x: 10, y: 20 };
/// let x_value = x_getter.get(&point); // x_value is 10
/// ```
///
/// # See also:
///
/// [`HasGetter`]: base trait for optics that provides a potentially fallible getter operation.