defaulted 0.1.1

Trait and derive macro for testing whether a value equals its default state, with per-field customization and optional serde integration
Documentation
/// 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
///     }
/// }
/// ```
pub trait Defaulted
{
    /// Returns `true` if `self` equals its default state.
    fn is_defaulted(&self) -> bool;
}