[−][src]Struct ouroboros_examples::BoxAndRef
A simple struct which contains a Box<i32>
and a &'this i32
.
Implementations
impl BoxAndRef
[src]
pub fn new(
data: Box<i32>,
data_ref_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> &'this i32
) -> Self
[src]
data: Box<i32>,
data_ref_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> &'this i32
) -> Self
Constructs a new instance of this self-referential struct. (See also BoxAndRefBuilder::build()
). Each argument is a field of the new struct. Fields that refer to other fields inside the struct are initialized using functions instead of directly passing their value. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> data_ref: _ |
pub fn try_new<Error_>(
data: Box<i32>,
data_ref_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> Result<&'this i32, Error_>
) -> Result<Self, Error_>
[src]
data: Box<i32>,
data_ref_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> Result<&'this i32, Error_>
) -> Result<Self, Error_>
(See also BoxAndRefTryBuilder::try_build()
.) Like new
, but builders for self-referencing fields can return results. If any of them fail, Err
is returned. If all of them succeed, Ok
is returned. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> Result<data_ref: _, Error_> |
pub fn try_new_or_recover<Error_>(
data: Box<i32>,
data_ref_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> Result<&'this i32, Error_>
) -> Result<Self, (Error_, Heads)>
[src]
data: Box<i32>,
data_ref_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> Result<&'this i32, Error_>
) -> Result<Self, (Error_, Heads)>
(See also BoxAndRefTryBuilder::try_build_or_recover()
.) Like try_new
, but all head fields are returned in the case of an error. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> Result<data_ref: _, Error_> |
pub fn with_data_contents<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow <Box<i32> as Deref>::Target) -> ReturnType
) -> ReturnType
[src]
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow <Box<i32> as Deref>::Target) -> ReturnType
) -> ReturnType
Provides limited immutable access to the contents of data
. This method was generated because data
is immutably borrowed by other fields.
pub fn with_data_ref<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow &'this i32) -> ReturnType
) -> ReturnType
[src]
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow &'this i32) -> ReturnType
) -> ReturnType
Provides an immutable reference to data_ref
. This method was generated because data_ref
is a tail field.
pub fn with_data_ref_mut<'outer_borrow, ReturnType>(
&'outer_borrow mut self,
user: impl for<'this> FnOnce(&'outer_borrow mut &'this i32) -> ReturnType
) -> ReturnType
[src]
&'outer_borrow mut self,
user: impl for<'this> FnOnce(&'outer_borrow mut &'this i32) -> ReturnType
) -> ReturnType
Provides a mutable reference to data_ref
. This method was generated because data_ref
is a tail field.
pub fn with<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(BorrowedFields<'outer_borrow, 'this>) -> ReturnType
) -> ReturnType
[src]
&'outer_borrow self,
user: impl for<'this> FnOnce(BorrowedFields<'outer_borrow, 'this>) -> ReturnType
) -> ReturnType
This method provides immutable references to all tail and immutably borrowed fields.
pub fn with_mut<'outer_borrow, ReturnType>(
&'outer_borrow mut self,
user: impl for<'this> FnOnce(BorrowedMutFields<'outer_borrow, 'this>) -> ReturnType
) -> ReturnType
[src]
&'outer_borrow mut self,
user: impl for<'this> FnOnce(BorrowedMutFields<'outer_borrow, 'this>) -> ReturnType
) -> ReturnType
This method provides mutable references to all tail fields.
pub fn into_heads(self) -> Heads
[src]
This function drops all internally referencing fields and returns only the head fields of this struct.
Auto Trait Implementations
impl RefUnwindSafe for BoxAndRef
impl Send for BoxAndRef
impl Sync for BoxAndRef
impl Unpin for BoxAndRef
impl UnwindSafe for BoxAndRef
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,