pub struct DynamicDefault { /* private fields */ }Expand description
An application-supplied dynamic default with an explicit semantic revision, computed from earlier answers instead of declared statically.
Real interactive flows need context-dependent defaults — a field whose
sensible default depends on how an earlier question was answered. The
closure receives an EarlierAnswers view of the decoded answers that
precede this field in the same scope chain and returns the default text,
which then runs through the exact same kind / constraint / validator
pipeline as any submitted answer, identically across interactive, file,
and stdin collection.
Because closure semantics cannot be fingerprinted, the application
declares an explicit revision string that enters the
fingerprint in place of a static default
value — exactly the FieldValidator revision contract: bump the
revision whenever the computed defaults change, and previously rendered
sheets are invalidated like any other semantic change. The closure itself
never affects the fingerprint.
§Dependency contract
Like a condition, a dynamic default may only
depend on fields declared before its own field, in the same group or an
enclosing one. Construction cannot introspect the closure to enforce
this, so the walk order defines the failure behavior instead: the
EarlierAnswers view resolves lookups against the answers decoded so
far, and a later-declared, out-of-scope, unknown, unanswered, or inactive
field simply reads as None. The closure must return a usable default
for every combination of Nones it can observe.
Implementations§
Trait Implementations§
Source§impl Clone for DynamicDefault
impl Clone for DynamicDefault
Source§fn clone(&self) -> DynamicDefault
fn clone(&self) -> DynamicDefault
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 DynamicDefault
impl Debug for DynamicDefault
impl Eq for DynamicDefault
Source§impl PartialEq for DynamicDefault
Equality compares the semantic revision only; the closure itself is not
comparable, and the revision is the declared semantic identity.
impl PartialEq for DynamicDefault
Equality compares the semantic revision only; the closure itself is not comparable, and the revision is the declared semantic identity.
Auto Trait Implementations§
impl !RefUnwindSafe for DynamicDefault
impl !UnwindSafe for DynamicDefault
impl Freeze for DynamicDefault
impl Send for DynamicDefault
impl Sync for DynamicDefault
impl Unpin for DynamicDefault
impl UnsafeUnpin for DynamicDefault
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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