pub trait FromPartial<T>: Sized {
// Required method
fn from(partial: T) -> Result<Self>;
// Provided methods
fn from_option(partial: Option<T>, error_missing: &str) -> Result<Self> { ... }
fn join(
first: Option<SpannedValue<T>>,
second: SpannedValue<T>,
specified_twice_error: &str,
) -> Result<Option<SpannedValue<T>>> { ... }
}
Expand description
Converts from a Partial
value.
Required Methods§
Sourcefn from(partial: T) -> Result<Self>
fn from(partial: T) -> Result<Self>
Creates Self
from T
.
§Errors
Returns a syn::Error
when T
does not represent a valid Self
,
e.g., due to missing or conflicting fields.
Provided Methods§
Sourcefn from_option(partial: Option<T>, error_missing: &str) -> Result<Self>
fn from_option(partial: Option<T>, error_missing: &str) -> Result<Self>
Sourcefn join(
first: Option<SpannedValue<T>>,
second: SpannedValue<T>,
specified_twice_error: &str,
) -> Result<Option<SpannedValue<T>>>
fn join( first: Option<SpannedValue<T>>, second: SpannedValue<T>, specified_twice_error: &str, ) -> Result<Option<SpannedValue<T>>>
Defines how two arguments for the same parameter should be handled.
§Errors
The default implementation errors if first
is already present and
specified_twice_error
is returned with the correct spans.
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.