Struct ouroboros_examples::ChainHack [−][src]
A chain of references, where c references b which references a. This is an example of a struct which requires using chain_hack as of the time this was written.
Implementations
impl ChainHack
[src]
pub(crate) fn new(
a: Box<i32>,
b_builder: impl for<'this> FnOnce(&'this i32) -> Arc<&'this i32>,
c_builder: impl for<'this> FnOnce(&'this &'this i32) -> Rc<&'this i32>
) -> ChainHack
[src]
a: Box<i32>,
b_builder: impl for<'this> FnOnce(&'this i32) -> Arc<&'this i32>,
c_builder: impl for<'this> FnOnce(&'this &'this i32) -> Rc<&'this i32>
) -> ChainHack
Constructs a new instance of this self-referential struct. (See also ChainHackBuilder::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 |
---|---|
a | Directly pass in the value this field should contain |
b_builder | Use a function or closure: (a: &_) -> b: _ |
c_builder | Use a function or closure: (b: &_) -> c: _ |
pub(crate) async fn new_async(
a: Box<i32>,
b_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = Arc<&'this i32>> + 'this>>,
c_builder: impl for<'this> FnOnce(&'this &'this i32) -> Pin<Box<dyn Future<Output = Rc<&'this i32>> + 'this>>
) -> ChainHack
[src]
a: Box<i32>,
b_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = Arc<&'this i32>> + 'this>>,
c_builder: impl for<'this> FnOnce(&'this &'this i32) -> Pin<Box<dyn Future<Output = Rc<&'this i32>> + 'this>>
) -> ChainHack
Constructs a new instance of this self-referential struct. (See also ChainHackAsyncBuilder::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 |
---|---|
a | Directly pass in the value this field should contain |
b_builder | Use a function or closure: (a: &_) -> b: _ |
c_builder | Use a function or closure: (b: &_) -> c: _ |
pub(crate) fn try_new<Error_>(
a: Box<i32>,
b_builder: impl for<'this> FnOnce(&'this i32) -> Result<Arc<&'this i32>, Error_>,
c_builder: impl for<'this> FnOnce(&'this &'this i32) -> Result<Rc<&'this i32>, Error_>
) -> Result<Self, Error_>
[src]
a: Box<i32>,
b_builder: impl for<'this> FnOnce(&'this i32) -> Result<Arc<&'this i32>, Error_>,
c_builder: impl for<'this> FnOnce(&'this &'this i32) -> Result<Rc<&'this i32>, Error_>
) -> Result<Self, Error_>
(See also ChainHackTryBuilder::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 |
---|---|
a | Directly pass in the value this field should contain |
b_builder | Use a function or closure: (a: &_) -> Result<b: _, Error_> |
c_builder | Use a function or closure: (b: &_) -> Result<c: _, Error_> |
pub(crate) fn try_new_or_recover<Error_>(
a: Box<i32>,
b_builder: impl for<'this> FnOnce(&'this i32) -> Result<Arc<&'this i32>, Error_>,
c_builder: impl for<'this> FnOnce(&'this &'this i32) -> Result<Rc<&'this i32>, Error_>
) -> Result<Self, (Error_, Heads)>
[src]
a: Box<i32>,
b_builder: impl for<'this> FnOnce(&'this i32) -> Result<Arc<&'this i32>, Error_>,
c_builder: impl for<'this> FnOnce(&'this &'this i32) -> Result<Rc<&'this i32>, Error_>
) -> Result<Self, (Error_, Heads)>
(See also ChainHackTryBuilder::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 |
---|---|
a | Directly pass in the value this field should contain |
b_builder | Use a function or closure: (a: &_) -> Result<b: _, Error_> |
c_builder | Use a function or closure: (b: &_) -> Result<c: _, Error_> |
pub(crate) fn with_a<'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 a
. This method was generated because the contents of a
are immutably borrowed by other fields.
pub(crate) fn borrow_a<'this>(&'this self) -> &'this Box<i32>
[src]
Provides limited immutable access to a
. This method was generated because the contents of a
are immutably borrowed by other fields.
pub(crate) fn with_b<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow Arc<&'this i32>) -> ReturnType
) -> ReturnType
[src]
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow Arc<&'this i32>) -> ReturnType
) -> ReturnType
Provides limited immutable access to b
. This method was generated because the contents of b
are immutably borrowed by other fields.
pub(crate) fn borrow_b<'this>(&'this self) -> &'this Arc<&'this i32>
[src]
Provides limited immutable access to b
. This method was generated because the contents of b
are immutably borrowed by other fields.
pub(crate) fn with_c<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow Rc<&'this i32>) -> ReturnType
) -> ReturnType
[src]
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow Rc<&'this i32>) -> ReturnType
) -> ReturnType
Provides an immutable reference to c
. This method was generated because c
is a tail field.
pub(crate) fn borrow_c<'this>(&'this self) -> &'this Rc<&'this i32>
[src]
Provides an immutable reference to c
. This method was generated because c
is a tail field.
pub(crate) fn with_c_mut<'outer_borrow, ReturnType>(
&'outer_borrow mut self,
user: impl for<'this> FnOnce(&'outer_borrow mut Rc<&'this i32>) -> ReturnType
) -> ReturnType
[src]
&'outer_borrow mut self,
user: impl for<'this> FnOnce(&'outer_borrow mut Rc<&'this i32>) -> ReturnType
) -> ReturnType
Provides a mutable reference to c
. This method was generated because c
is a tail field. No borrow_c_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 ChainHack
impl !Send for ChainHack
impl !Sync for ChainHack
impl Unpin for ChainHack
impl UnwindSafe for ChainHack
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>,