pub trait Applicable: Sized {
type Base;
// Required methods
fn apply_to(self, base: &mut Self::Base);
fn apply_to_opt(self, other: &mut Self);
fn can_convert(&self) -> bool;
// Provided methods
fn build(self, base: Self::Base) -> Self::Base { ... }
fn apply(self, other: Self) -> Self { ... }
}Expand description
The trait is implemented for every generated structure. Thanks to this, you can use optional_struct in generic contexts. You should never have to implement this manually.
Required Associated Types§
Required Methods§
Sourcefn apply_to(self, base: &mut Self::Base)
fn apply_to(self, base: &mut Self::Base)
Similar to Applicable::build, but takes the Base by reference.
Sourcefn apply_to_opt(self, other: &mut Self)
fn apply_to_opt(self, other: &mut Self)
Applies the fields of this structure to another optional_struct. The fields on the “left” (from self) are applied iff they are set. E.g.: self.a == Some(Foo) and other.a == Some(Bar) => other.a == Some(Foo) self.a == None and other.a == Some(Bar) => other.a == Some(Bar) (where the arrow means, after calling this function) This function is also called recursively, and supports nested structures.
Sourcefn can_convert(&self) -> bool
fn can_convert(&self) -> bool
Signals whether the optional_struct has all its fields set to convert it to a Base. i.e. self.can_convert() == Base::try_from(self).is_ok()
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.