Skip to main content

Fold

Struct Fold 

Source
pub struct Fold<'a> { /* private fields */ }
Expand description

Reading a whole settings struct out of one resolution.

Generated code reads each field in turn and calls Fold::finish once, which is what makes the errors a list rather than the first thing that went wrong.

Implementations§

Source§

impl Fold<'_>

Source

pub fn optional<T: FromValue>(&mut self, id: PropId) -> Option<T>

A setting that may have no value, as Option<T>.

Absence is not an error here: a setting with no default and nothing set is a field that holds None, which is what option<T> in the spec means.

Source

pub fn required<T: FromValue>(&mut self, id: PropId) -> Option<T>

A setting that must have a value, for a field that is not an Option.

Returns None only when it has recorded an error, so code that has already called Fold::finish and found it Ok may unwrap what this returned. That is the contract generated code is written against: the fold reports, and the struct is built afterwards.

Source

pub fn errors(&self) -> &[ReadError]

What has gone wrong so far, for a caller that wants to add to the list.

Source

pub fn finish(self) -> Result<(), ReadErrors>

Every setting read, or every reason one could not be.

Source

pub fn into_errors(self) -> ReadErrors

Everything that went wrong, whether or not anything did.

What a lossy fold ends with: Fold::finish answers “did this work”, and the answer there is always “not entirely” or the caller would not be folding lossily.

Auto Trait Implementations§

§

impl<'a> Freeze for Fold<'a>

§

impl<'a> RefUnwindSafe for Fold<'a>

§

impl<'a> Send for Fold<'a>

§

impl<'a> Sync for Fold<'a>

§

impl<'a> Unpin for Fold<'a>

§

impl<'a> UnsafeUnpin for Fold<'a>

§

impl<'a> UnwindSafe for Fold<'a>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.