[][src]Struct ouroboros_examples::BoxAndRefTryBuilder

pub struct BoxAndRefTryBuilder<DataRefBuilder_: for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> Result<&'this i32, Error_>, Error_> {
    pub data: Box<i32>,
    pub data_ref_builder: DataRefBuilder_,
}

A more verbose but stable way to construct self-referencing structs. It is comparable to using StructName { field1: value1, field2: value2 } rather than StructName::new(value1, value2). This has the dual benefit of makin your code both easier to refactor and more readable. Call try_build() or try_build_or_recover() to construct the actual struct. The fields of this struct should be used as follows:

FieldSuggested Use
dataDirectly pass in the value this field should contain
data_ref_builderUse a function or closure: (data: &_) -> Result<data_ref: _, Error_>

Fields

data: Box<i32>data_ref_builder: DataRefBuilder_

Implementations

impl<DataRefBuilder_: for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> Result<&'this i32, Error_>, Error_> BoxAndRefTryBuilder<DataRefBuilder_, Error_>[src]

pub fn try_build(self) -> Result<BoxAndRef, Error_>[src]

Calls BoxAndRef::try_new() using the provided values. This is preferrable over calling try_new() directly for the reasons listed above.

pub fn try_build_or_recover(self) -> Result<BoxAndRef, (Error_, Heads)>[src]

Calls BoxAndRef::try_new_or_recover() using the provided values. This is preferrable over calling try_new_or_recover() directly for the reasons listed above.

Auto Trait Implementations

impl<DataRefBuilder_, Error_> RefUnwindSafe for BoxAndRefTryBuilder<DataRefBuilder_, Error_> where
    DataRefBuilder_: RefUnwindSafe

impl<DataRefBuilder_, Error_> Send for BoxAndRefTryBuilder<DataRefBuilder_, Error_> where
    DataRefBuilder_: Send

impl<DataRefBuilder_, Error_> Sync for BoxAndRefTryBuilder<DataRefBuilder_, Error_> where
    DataRefBuilder_: Sync

impl<DataRefBuilder_, Error_> Unpin for BoxAndRefTryBuilder<DataRefBuilder_, Error_> where
    DataRefBuilder_: Unpin

impl<DataRefBuilder_, Error_> UnwindSafe for BoxAndRefTryBuilder<DataRefBuilder_, Error_> where
    DataRefBuilder_: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.