pub struct BooleanDefaultTrue(pub Option<bool>);Expand description
Boolean that defaults to true when None.
A newtype around Option<bool> that dereferences to true when the inner
value is None or Some(true). Serializes transparently as Option<bool>
on the wire and in JSON.
Tuple Fields§
§0: Option<bool>Implementations§
Source§impl BooleanDefaultTrue
impl BooleanDefaultTrue
Sourcepub fn is_none(&self) -> bool
pub fn is_none(&self) -> bool
Returns true if the inner value is None.
Used by serde skip_serializing_if to omit fields that were absent in
the source JSON (or constructed via none()), matching TS’s
JSON.stringify(undefined) omission. Explicit Some(true) /
Some(false) round-trip as true / false.
Sourcepub fn none() -> Self
pub fn none() -> Self
Constructs the “absent” representation: Self(None).
Used as a serde default for missing-field deserialization so the
distinction between “field absent” (round-trips as omitted) and “field
present at default value” (round-trips as the explicit value) is
preserved. Default::default() still returns Self(Some(true)) for
runtime convenience — None is reserved for the wire-absent state.
Trait Implementations§
Source§impl Clone for BooleanDefaultTrue
impl Clone for BooleanDefaultTrue
Source§fn clone(&self) -> BooleanDefaultTrue
fn clone(&self) -> BooleanDefaultTrue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more