pub struct OwnedTree { /* private fields */ }
Expand description
Implementations§
Source§impl OwnedTree
impl OwnedTree
Sourcepub fn new(
owner: String,
dependent_builder: impl for<'_q> FnOnce(&'_q String) -> Tree<'_q>,
) -> Self
pub fn new( owner: String, dependent_builder: impl for<'_q> FnOnce(&'_q String) -> Tree<'_q>, ) -> Self
Constructs a new self-referential struct.
The provided owner
will be moved into a heap allocated box. Followed by construction
of the dependent value, by calling dependent_builder
with a shared reference to the
owner that remains valid for the lifetime of the constructed struct.
Sourcepub fn try_new<Err>(
owner: String,
dependent_builder: impl for<'_q> FnOnce(&'_q String) -> Result<Tree<'_q>, Err>,
) -> Result<Self, Err>
pub fn try_new<Err>( owner: String, dependent_builder: impl for<'_q> FnOnce(&'_q String) -> Result<Tree<'_q>, Err>, ) -> Result<Self, Err>
Constructs a new self-referential struct or returns an error.
Consumes owner on error.
Sourcepub fn try_new_or_recover<Err>(
owner: String,
dependent_builder: impl for<'_q> FnOnce(&'_q String) -> Result<Tree<'_q>, Err>,
) -> Result<Self, (String, Err)>
pub fn try_new_or_recover<Err>( owner: String, dependent_builder: impl for<'_q> FnOnce(&'_q String) -> Result<Tree<'_q>, Err>, ) -> Result<Self, (String, Err)>
Constructs a new self-referential struct or returns an error.
Returns owner and error as tuple on error.
Sourcepub fn borrow_owner<'_q>(&'_q self) -> &'_q String
pub fn borrow_owner<'_q>(&'_q self) -> &'_q String
Borrows owner.
Sourcepub fn with_dependent<'outer_fn, Ret>(
&'outer_fn self,
func: impl for<'_q> FnOnce(&'_q String, &'outer_fn Tree<'_q>) -> Ret,
) -> Ret
pub fn with_dependent<'outer_fn, Ret>( &'outer_fn self, func: impl for<'_q> FnOnce(&'_q String, &'outer_fn Tree<'_q>) -> Ret, ) -> Ret
Calls given closure func
with a shared reference to dependent.
Sourcepub fn with_dependent_mut<'outer_fn, Ret>(
&'outer_fn mut self,
func: impl for<'_q> FnOnce(&'_q String, &'outer_fn mut Tree<'_q>) -> Ret,
) -> Ret
pub fn with_dependent_mut<'outer_fn, Ret>( &'outer_fn mut self, func: impl for<'_q> FnOnce(&'_q String, &'outer_fn mut Tree<'_q>) -> Ret, ) -> Ret
Calls given closure func
with an unique reference to dependent.
Sourcepub fn borrow_dependent<'_q>(&'_q self) -> &'_q Tree<'_q>
pub fn borrow_dependent<'_q>(&'_q self) -> &'_q Tree<'_q>
Borrows dependent.
Sourcepub fn into_owner(self) -> String
pub fn into_owner(self) -> String
Consumes self
and returns the the owner.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OwnedTree
impl RefUnwindSafe for OwnedTree
impl Send for OwnedTree
impl Sync for OwnedTree
impl Unpin for OwnedTree
impl UnwindSafe for OwnedTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more