pub enum DefaultValue {
Show 13 variants
BoolLiteral(bool),
StringLiteral(String),
IntLiteral(i64),
FloatLiteral(f64),
EnumVariant(String),
TupleVariant(String, Vec<DefaultValue>),
StructVariant(String, Vec<(String, DefaultValue)>),
FunctionCall(String),
PublicFunctionCall(String),
ListLiteral(Vec<DefaultValue>),
Empty,
Unresolved(String),
None,
}Expand description
Typed default value for a field, enabling backends to emit language-native defaults.
Variants§
BoolLiteral(bool)
StringLiteral(String)
IntLiteral(i64)
FloatLiteral(f64)
EnumVariant(String)
TupleVariant(String, Vec<DefaultValue>)
A tuple-variant enum default (Mode::Custom(5)), each positional argument folded
independently and kept in source order. Distinct from DefaultValue::EnumVariant,
which names a bare unit-variant path with no arguments of its own.
Produced only when every argument itself folds to a value-carrying DefaultValue (see
extract::extractor::defaults::carries_value); a call with even one unfoldable argument
keeps the whole field DefaultValue::Unresolved rather than a partially-known payload
— rendering some arguments as literals and silently dropping the rest would be a subtler
instance of the fabrication Unresolved exists to prevent. ~keep
StructVariant(String, Vec<(String, DefaultValue)>)
A struct-variant enum default (Kind::Curated { label: "balanced".to_string() }), each
named field folded independently and kept in source order. Same all-or-nothing rule and
rationale as DefaultValue::TupleVariant. ~keep
FunctionCall(String)
A zero-argument Rust function that supplies the value at runtime. ~keep
PublicFunctionCall(String)
A public zero-argument Rust function callable from generated binding crates. ~keep
ListLiteral(Vec<DefaultValue>)
A non-empty collection literal, holding its elements in source order.
A genuinely empty vec![]/Vec::new() stays DefaultValue::Empty: the two are
distinct because every backend already renders “the empty collection” natively, whereas
this variant carries elements that have to be rendered individually. Only produced when
every element is itself representable — anything else falls back to Empty, so a
backend never emits a default that silently differs from the Rust one. ~keep
Empty
Empty collection or Default::default() — the type’s own zero, and known to be exactly
what the Rust default is. Contrast DefaultValue::Unresolved. ~keep
Unresolved(String)
The extractor found the type’s Default implementation but could not read a value out
of it: the body is neither a struct literal nor a delegation alef can constant-fold
(Self::builder().build(), a match, a computed constructor).
Distinct from DefaultValue::Empty, and the distinction is the entire point of the
variant. Empty asserts “the default is exactly this type’s zero” — true for
#[derive(Default)], for Vec::new(), for Default::default() — so a backend
substituting its target language’s zero is exact. Unresolved asserts the opposite:
alef does not know the value, and a zero would be a guess.
Before this variant existed both wrote Empty, so one enum value carried “exact” and
“guess” at once and nothing could tell them apart. Every per-field-literal backend
(C#, Java, Kotlin, Swift, Python, Go) then shipped its type-zero directly underneath a
generated doc comment quoting the real Rust default — the value the extractor had
already read out of the same doc prose.
The payload is the source text of the fn default() body that could not be read, so a
diagnostic can name it. ~keep
None
None / null
Trait Implementations§
Source§impl Clone for DefaultValue
impl Clone for DefaultValue
Source§fn clone(&self) -> DefaultValue
fn clone(&self) -> DefaultValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DefaultValue
impl Debug for DefaultValue
Source§impl<'de> Deserialize<'de> for DefaultValue
impl<'de> Deserialize<'de> for DefaultValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for DefaultValue
impl PartialEq for DefaultValue
Source§impl Serialize for DefaultValue
impl Serialize for DefaultValue
impl StructuralPartialEq for DefaultValue
Auto Trait Implementations§
impl Freeze for DefaultValue
impl RefUnwindSafe for DefaultValue
impl Send for DefaultValue
impl Sync for DefaultValue
impl Unpin for DefaultValue
impl UnsafeUnpin for DefaultValue
impl UnwindSafe for DefaultValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more