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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/// Set a new value, or compute it using a closure.
///
/// # Examples
///
/// ```rust
/// use up_set::UpSet;
///
/// #[derive(Debug, Eq, PartialEq)]
/// struct Person {
/// age: u8
/// }
///
/// impl Person {
/// fn age<M, U: UpSet<u8, M>>(mut self, up_set: U) -> Self {
/// self.age = up_set.up_set(self.age);
/// self
/// }
/// }
///
/// // Set age to 4
/// assert_eq!(Person { age: 55 }.age(4), Person { age: 4 });
///
/// // Add +4 to existing age
/// assert_eq!(Person { age: 55 }.age(|age| age + 4), Person { age: 59 });
/// ```
///
/// See the crate-level documentation for more info.
/// Marker enum to guide Rust's type-inference system.
///
/// Without this, it will consider the 2 implementations of `UpSet`:
///
/// - `impl<T, F: FnOnce(T) -> T> UpSet<T> for F`
/// - `impl<T> UpSet<T> for T`
///
/// To be overlapping, due to Rust not having [specialization].
///
/// [specialization]: https://github.com/rust-lang/rust/issues/31844
/// Marker enum to guide Rust's type-inference system.
///
/// Without this, it will consider the 2 implementations of `UpSet`:
///
/// - `impl<T, F: FnOnce(T) -> T> UpSet<T> for F`
/// - `impl<T> UpSet<T> for T`
///
/// To be overlapping, due to Rust not having [specialization].
///
/// [specialization]: https://github.com/rust-lang/rust/issues/31844