[−][src]Struct ouroboros_examples::DocumentationExample
The example provided in the documentation.
Implementations
impl DocumentationExample
[src]
pub(crate) fn new(
int_data: Box<i32>,
float_data: Box<f32>,
int_reference_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> &'this i32,
float_reference_builder: impl for<'this> FnOnce(&'this mut <Box<f32> as Deref>::Target) -> &'this mut f32
) -> Self
[src]
int_data: Box<i32>,
float_data: Box<f32>,
int_reference_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> &'this i32,
float_reference_builder: impl for<'this> FnOnce(&'this mut <Box<f32> as Deref>::Target) -> &'this mut f32
) -> Self
Constructs a new instance of this self-referential struct. (See also DocumentationExampleBuilder::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 |
---|---|
int_data | Directly pass in the value this field should contain |
float_data | Directly pass in the value this field should contain |
int_reference_builder | Use a function or closure: (int_data: &_) -> int_reference: _ |
float_reference_builder | Use a function or closure: (float_data: &mut _) -> float_reference: _ |
pub(crate) fn try_new<Error_>(
int_data: Box<i32>,
float_data: Box<f32>,
int_reference_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> Result<&'this i32, Error_>,
float_reference_builder: impl for<'this> FnOnce(&'this mut <Box<f32> as Deref>::Target) -> Result<&'this mut f32, Error_>
) -> Result<Self, Error_>
[src]
int_data: Box<i32>,
float_data: Box<f32>,
int_reference_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> Result<&'this i32, Error_>,
float_reference_builder: impl for<'this> FnOnce(&'this mut <Box<f32> as Deref>::Target) -> Result<&'this mut f32, Error_>
) -> Result<Self, Error_>
(See also DocumentationExampleTryBuilder::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 |
---|---|
int_data | Directly pass in the value this field should contain |
float_data | Directly pass in the value this field should contain |
int_reference_builder | Use a function or closure: (int_data: &_) -> Result<int_reference: _, Error_> |
float_reference_builder | Use a function or closure: (float_data: &mut _) -> Result<float_reference: _, Error_> |
pub(crate) fn try_new_or_recover<Error_>(
int_data: Box<i32>,
float_data: Box<f32>,
int_reference_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> Result<&'this i32, Error_>,
float_reference_builder: impl for<'this> FnOnce(&'this mut <Box<f32> as Deref>::Target) -> Result<&'this mut f32, Error_>
) -> Result<Self, (Error_, Heads)>
[src]
int_data: Box<i32>,
float_data: Box<f32>,
int_reference_builder: impl for<'this> FnOnce(&'this <Box<i32> as Deref>::Target) -> Result<&'this i32, Error_>,
float_reference_builder: impl for<'this> FnOnce(&'this mut <Box<f32> as Deref>::Target) -> Result<&'this mut f32, Error_>
) -> Result<Self, (Error_, Heads)>
(See also DocumentationExampleTryBuilder::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 |
---|---|
int_data | Directly pass in the value this field should contain |
float_data | Directly pass in the value this field should contain |
int_reference_builder | Use a function or closure: (int_data: &_) -> Result<int_reference: _, Error_> |
float_reference_builder | Use a function or closure: (float_data: &mut _) -> Result<float_reference: _, Error_> |
pub(crate) fn with_int_data<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow Box<i32>) -> ReturnType
) -> ReturnType
[src]
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow Box<i32>) -> ReturnType
) -> ReturnType
Provides limited immutable access to int_data
. This method was generated because the contents of int_data
are immutably borrowed by other fields.
pub(crate) fn borrow_int_data<'this>(&'this self) -> &'this Box<i32>
[src]
Provides limited immutable access to int_data
. This method was generated because the contents of int_data
are immutably borrowed by other fields.
pub(crate) fn with_int_reference<'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 int_reference
. This method was generated because int_reference
is a tail field.
pub(crate) fn with_int_reference_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 int_reference
. This method was generated because int_reference
is a tail field. No borrow_int_reference_mut
function was generated because Rust's borrow checker is currently unable to guarantee that such a method would be used safely.
pub(crate) fn borrow_int_reference<'this>(&'this self) -> &'this &'this i32
[src]
Provides a mutable reference to int_reference
. This method was generated because int_reference
is a tail field. No borrow_int_reference_mut
function was generated because Rust's borrow checker is currently unable to guarantee that such a method would be used safely.
pub(crate) fn with_float_reference<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow &'this mut f32) -> ReturnType
) -> ReturnType
[src]
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow &'this mut f32) -> ReturnType
) -> ReturnType
Provides an immutable reference to float_reference
. This method was generated because float_reference
is a tail field.
pub(crate) fn with_float_reference_mut<'outer_borrow, ReturnType>(
&'outer_borrow mut self,
user: impl for<'this> FnOnce(&'outer_borrow mut &'this mut f32) -> ReturnType
) -> ReturnType
[src]
&'outer_borrow mut self,
user: impl for<'this> FnOnce(&'outer_borrow mut &'this mut f32) -> ReturnType
) -> ReturnType
Provides a mutable reference to float_reference
. This method was generated because float_reference
is a tail field. No borrow_float_reference_mut
function was generated because Rust's borrow checker is currently unable to guarantee that such a method would be used safely.
pub(crate) fn borrow_float_reference<'this>(
&'this self
) -> &'this &'this mut f32
[src]
&'this self
) -> &'this &'this mut f32
Provides a mutable reference to float_reference
. This method was generated because float_reference
is a tail field. No borrow_float_reference_mut
function was generated because Rust's borrow checker is currently unable to guarantee that such a method would be used safely.
pub(crate) 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(crate) 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(crate) 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 DocumentationExample
[src]
impl Send for DocumentationExample
[src]
impl Sync for DocumentationExample
[src]
impl Unpin for DocumentationExample
[src]
impl !UnwindSafe for DocumentationExample
[src]
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,
pub 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.
pub 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>,