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
/// Returns `true` if a value equals its "default" state.
///
/// Unlike [`Default`], which *constructs* a default value, `Defaulted` tests
/// whether an *existing* value is still at that state. What counts as
/// "default" is type-defined: zero for numbers, `false` for booleans, empty
/// for strings and collections, `None` for `Option`, and so on.
///
/// # Deriving
///
/// Enable the `derive` feature and use `#[derive(Defaulted)]`:
///
/// ```rust
/// # #[cfg(feature = "derive")] {
/// use defaulted::Defaulted;
///
/// #[derive(Default, Defaulted)]
/// struct Point
/// {
/// x: f64,
/// y: f64,
/// }
///
/// assert!(Point::default().is_defaulted());
/// assert!(!Point { x: 1.0, y: 0.0 }.is_defaulted());
/// # }
/// ```
///
/// See the [crate-level documentation](crate) for the full set of per-field
/// and struct-level attributes.
///
/// # Implementing manually
///
/// ```rust
/// use defaulted::Defaulted;
///
/// struct Metres(f64);
///
/// impl Defaulted for Metres
/// {
/// fn is_defaulted(&self) -> bool
/// {
/// self.0 == 0.0
/// }
/// }
/// ```