Skip to main content

DefaultValue

Enum DefaultValue 

Source
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

Source§

fn clone(&self) -> DefaultValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DefaultValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DefaultValue

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for DefaultValue

Source§

fn eq(&self, other: &DefaultValue) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for DefaultValue

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DefaultValue

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more