Struct ouroboros_examples::WithConstParam
source · #[repr(transparent)]pub struct WithConstParam<T: 'static, const REV: bool> {
actual_data: MaybeUninit<WithConstParamInternal<T, REV>>,
}
Expand description
The self-referencing struct.
Fields§
§actual_data: MaybeUninit<WithConstParamInternal<T, REV>>
Implementations§
source§impl<T: 'static, const REV: bool> WithConstParam<T, REV>
impl<T: 'static, const REV: bool> WithConstParam<T, REV>
sourcepub fn new(
data: RefCell<T>,
dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Option<Box<Ext<'this, T, REV>>>
) -> WithConstParam<T, REV>
pub fn new( data: RefCell<T>, dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Option<Box<Ext<'this, T, REV>>> ) -> WithConstParam<T, REV>
Constructs a new instance of this self-referential struct. (See also WithConstParamBuilder::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 |
dref_builder | Use a function or closure: (data: &_) -> dref: _ |
sourcepub async fn new_async(
data: RefCell<T>,
dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Option<Box<Ext<'this, T, REV>>>> + 'this>>
) -> WithConstParam<T, REV>
pub async fn new_async( data: RefCell<T>, dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Option<Box<Ext<'this, T, REV>>>> + 'this>> ) -> WithConstParam<T, REV>
Constructs a new instance of this self-referential struct. (See also WithConstParamAsyncBuilder::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 |
dref_builder | Use a function or closure: (data: &_) -> dref: _ |
sourcepub async fn new_async_send(
data: RefCell<T>,
dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Option<Box<Ext<'this, T, REV>>>> + Send + 'this>>
) -> WithConstParam<T, REV>
pub async fn new_async_send( data: RefCell<T>, dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Option<Box<Ext<'this, T, REV>>>> + Send + 'this>> ) -> WithConstParam<T, REV>
Constructs a new instance of this self-referential struct. (See also WithConstParamAsyncSendBuilder::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 |
dref_builder | Use a function or closure: (data: &_) -> dref: _ |
sourcepub fn try_new<Error_>(
data: RefCell<T>,
dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Result<Option<Box<Ext<'this, T, REV>>>, Error_>
) -> Result<WithConstParam<T, REV>, Error_>
pub fn try_new<Error_>( data: RefCell<T>, dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Result<Option<Box<Ext<'this, T, REV>>>, Error_> ) -> Result<WithConstParam<T, REV>, Error_>
(See also WithConstParamTryBuilder::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 |
dref_builder | Use a function or closure: (data: &_) -> Result<dref: _, Error_> |
sourcepub fn try_new_or_recover<Error_>(
data: RefCell<T>,
dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Result<Option<Box<Ext<'this, T, REV>>>, Error_>
) -> Result<WithConstParam<T, REV>, (Error_, Heads<T, REV>)>
pub fn try_new_or_recover<Error_>( data: RefCell<T>, dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Result<Option<Box<Ext<'this, T, REV>>>, Error_> ) -> Result<WithConstParam<T, REV>, (Error_, Heads<T, REV>)>
(See also WithConstParamTryBuilder::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 |
dref_builder | Use a function or closure: (data: &_) -> Result<dref: _, Error_> |
sourcepub async fn try_new_async<Error_>(
data: RefCell<T>,
dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Result<Option<Box<Ext<'this, T, REV>>>, Error_>> + 'this>>
) -> Result<WithConstParam<T, REV>, Error_>
pub async fn try_new_async<Error_>( data: RefCell<T>, dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Result<Option<Box<Ext<'this, T, REV>>>, Error_>> + 'this>> ) -> Result<WithConstParam<T, REV>, Error_>
(See also WithConstParamAsyncTryBuilder::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 |
dref_builder | Use a function or closure: (data: &_) -> Result<dref: _, Error_> |
sourcepub async fn try_new_or_recover_async<Error_>(
data: RefCell<T>,
dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Result<Option<Box<Ext<'this, T, REV>>>, Error_>> + 'this>>
) -> Result<WithConstParam<T, REV>, (Error_, Heads<T, REV>)>
pub async fn try_new_or_recover_async<Error_>( data: RefCell<T>, dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Result<Option<Box<Ext<'this, T, REV>>>, Error_>> + 'this>> ) -> Result<WithConstParam<T, REV>, (Error_, Heads<T, REV>)>
(See also WithConstParamAsyncTryBuilder::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 |
dref_builder | Use a function or closure: (data: &_) -> Result<dref: _, Error_> |
sourcepub async fn try_new_async_send<Error_>(
data: RefCell<T>,
dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Result<Option<Box<Ext<'this, T, REV>>>, Error_>> + Send + 'this>>
) -> Result<WithConstParam<T, REV>, Error_>
pub async fn try_new_async_send<Error_>( data: RefCell<T>, dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Result<Option<Box<Ext<'this, T, REV>>>, Error_>> + Send + 'this>> ) -> Result<WithConstParam<T, REV>, Error_>
(See also WithConstParamAsyncSendTryBuilder::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 |
dref_builder | Use a function or closure: (data: &_) -> Result<dref: _, Error_> |
sourcepub async fn try_new_or_recover_async_send<Error_>(
data: RefCell<T>,
dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Result<Option<Box<Ext<'this, T, REV>>>, Error_>> + Send + 'this>>
) -> Result<WithConstParam<T, REV>, (Error_, Heads<T, REV>)>
pub async fn try_new_or_recover_async_send<Error_>( data: RefCell<T>, dref_builder: impl for<'this> FnOnce(&'this RefCell<T>) -> Pin<Box<dyn Future<Output = Result<Option<Box<Ext<'this, T, REV>>>, Error_>> + Send + 'this>> ) -> Result<WithConstParam<T, REV>, (Error_, Heads<T, REV>)>
(See also WithConstParamAsyncSendTryBuilder::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 |
dref_builder | Use a function or closure: (data: &_) -> Result<dref: _, Error_> |
sourcepub(crate) fn with_data<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow RefCell<T>) -> ReturnType
) -> ReturnType
pub(crate) fn with_data<'outer_borrow, ReturnType>( &'outer_borrow self, user: impl for<'this> FnOnce(&'outer_borrow RefCell<T>) -> ReturnType ) -> ReturnType
Provides limited immutable access to data
. This method was generated because the contents of data
are immutably borrowed by other fields.
sourcepub(crate) fn borrow_data<'this>(&'this self) -> &'this RefCell<T>
pub(crate) fn borrow_data<'this>(&'this self) -> &'this RefCell<T>
Provides limited immutable access to data
. This method was generated because the contents of data
are immutably borrowed by other fields.
sourcepub(crate) fn with_dref<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow Option<Box<Ext<'this, T, REV>>>) -> ReturnType
) -> ReturnType
pub(crate) fn with_dref<'outer_borrow, ReturnType>( &'outer_borrow self, user: impl for<'this> FnOnce(&'outer_borrow Option<Box<Ext<'this, T, REV>>>) -> ReturnType ) -> ReturnType
Provides an immutable reference to dref
. This method was generated because dref
is a tail field.
sourcepub(crate) fn with_dref_mut<'outer_borrow, ReturnType>(
&'outer_borrow mut self,
user: impl for<'this> FnOnce(&'outer_borrow mut Option<Box<Ext<'this, T, REV>>>) -> ReturnType
) -> ReturnType
pub(crate) fn with_dref_mut<'outer_borrow, ReturnType>( &'outer_borrow mut self, user: impl for<'this> FnOnce(&'outer_borrow mut Option<Box<Ext<'this, T, REV>>>) -> ReturnType ) -> ReturnType
Provides a mutable reference to dref
. This method was generated because dref
is a tail field. No borrow_dref_mut
function was generated because Rust’s borrow checker is currently unable to guarantee that such a method would be used safely.
sourcepub fn with<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(BorrowedFields<'outer_borrow, 'this, T, REV>) -> ReturnType
) -> ReturnType
pub fn with<'outer_borrow, ReturnType>( &'outer_borrow self, user: impl for<'this> FnOnce(BorrowedFields<'outer_borrow, 'this, T, REV>) -> ReturnType ) -> ReturnType
This method provides immutable references to all tail and immutably borrowed fields.
sourcepub fn with_mut<'outer_borrow, ReturnType>(
&'outer_borrow mut self,
user: impl for<'this0, 'this1> FnOnce(BorrowedMutFields<'outer_borrow, 'this1, 'this0, T, REV>) -> ReturnType
) -> ReturnType
pub fn with_mut<'outer_borrow, ReturnType>( &'outer_borrow mut self, user: impl for<'this0, 'this1> FnOnce(BorrowedMutFields<'outer_borrow, 'this1, 'this0, T, REV>) -> ReturnType ) -> ReturnType
This method provides mutable references to all tail fields.
sourcepub fn into_heads(self) -> Heads<T, REV>
pub fn into_heads(self) -> Heads<T, REV>
This function drops all internally referencing fields and returns only the head fields of this struct.