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§

source

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§

source

fn from_option(partial: Option<T>, error_missing: &str) -> Result<Self>

Creates Self from optional T.

§Errors

The default implementation errors with error_missing when partial is None, or when Self::from errors.

Implementors might override this for types with expected default values.

source

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T: FromPartial<P>, P> FromPartial<Partial<Option<P>>> for Option<T>

source§

fn from(partial: Partial<Option<P>>) -> Result<Self>

source§

impl<T: FromPartial<P>, P> FromPartial<Partial<Vec<P>>> for Vec<T>

source§

fn from(partial: Partial<Vec<P>>) -> Result<Self>

source§

fn join( first: Option<SpannedValue<Partial<Vec<P>>>>, second: SpannedValue<Partial<Vec<P>>>, _: &str ) -> Result<Option<SpannedValue<Partial<Vec<P>>>>>

Implementors§