Struct rental::common::RentRefCellMut[][src]

pub struct RentRefCellMut<H: 'static + StableDeref + DerefMut, T: 'static> { /* fields omitted */ }

Stores a RefCell and a RefMut in the same struct.

use std::cell;

let mut r = RentRefCellMut::new(Box::new(cell::RefCell::new(5)), |c| c.borrow_mut());
*r = 12;
assert_eq!(12, RentRefCellMut::rent(&r, |c| **c));

Methods

impl<H: 'static + StableDeref + DerefMut, T: 'static> RentRefCellMut<H, T>
[src]

Create a new instance of the rental struct.

The first argument provided is the head, followed by a series of closures, one for each tail field. Each of these closures will receive, as its arguments, a borrow of the previous field, followed by borrows of the remaining prefix fields if the struct is a shared rental. If the struct is a mutable rental, only the immediately preceding field is passed.

Attempt to create a new instance of the rental struct.

As new, but each closure returns a Result. If one of them fails, execution is short-circuited and a tuple of the error and the original head value is returned to you.

Attempt to create a new instance of the rental struct.

As try_new, but only the error value is returned upon failure; the head value is dropped. This method interacts more smoothly with existing error conversions.

Return lifetime-erased shared borrows of the fields of the struct.

This is unsafe because the erased lifetimes are fake. Use this only if absolutely necessary and be very mindful of what the true lifetimes are.

Return a lifetime-erased mutable borrow of the suffix of the struct.

This is unsafe because the erased lifetimes are fake. Use this only if absolutely necessary and be very mindful of what the true lifetimes are.

Execute a closure on the shared suffix of the struct.

The closure may return any value not bounded by one of the special rentail lifetimes of the struct.

Execute a closure on the mutable suffix of the struct.

The closure may return any value not bounded by one of the special rentail lifetimes of the struct.

Important traits for &'a mut R

Return a shared reference from the shared suffix of the struct.

This is a subtle variation of rent where it is legal to return a reference bounded by a rental lifetime, because that lifetime is reborrowed away before it is returned to you.

Optionally return a shared reference from the shared suffix of the struct.

This is a subtle variation of rent where it is legal to return a reference bounded by a rental lifetime, because that lifetime is reborrowed away before it is returned to you.

Try to return a shared reference from the shared suffix of the struct, or an error on failure.

This is a subtle variation of rent where it is legal to return a reference bounded by a rental lifetime, because that lifetime is reborrowed away before it is returned to you.

Important traits for &'a mut R

Return a mutable reference from the mutable suffix of the struct.

This is a subtle variation of rent_mut where it is legal to return a reference bounded by a rental lifetime, because that lifetime is reborrowed away before it is returned to you.

Optionally return a mutable reference from the mutable suffix of the struct.

This is a subtle variation of rent_mut where it is legal to return a reference bounded by a rental lifetime, because that lifetime is reborrowed away before it is returned to you.

Try to return a mutable reference from the mutable suffix of the struct, or an error on failure.

This is a subtle variation of rent_mut where it is legal to return a reference bounded by a rental lifetime, because that lifetime is reborrowed away before it is returned to you.

Drop the rental struct and return the original head value to you.

impl<H: 'static + StableDeref + DerefMut, T: 'static> RentRefCellMut<H, T>
[src]

Borrow all fields of the struct by reborrowing away the rental lifetimes.

This is safe because the lifetimes are verified to be covariant first.

Borrow the suffix field of the struct by reborrowing away the rental lifetimes.

This is safe because the lifetimes are verified to be covariant first.

impl<H: 'static + StableDeref + DerefMut, T: 'static> RentRefCellMut<H, T>
[src]

Maps the suffix field of the rental struct to a different type.

Consumes the rental struct and applies the closure to the suffix field. A new rental struct is then constructed with the original prefix and new suffix.

Try to map the suffix field of the rental struct to a different type.

As map, but the closure may fail. Upon failure, the tail is dropped, and the error is returned to you along with the head.

Try to map the suffix field of the rental struct to a different type.

As map, but the closure may fail. Upon failure, the struct is dropped and the error is returned.

Trait Implementations

impl<H: 'static + StableDeref + DerefMut, T: 'static> Debug for RentRefCellMut<H, T> where
    RefMut<'static, T>: Debug
[src]

Formats the value using the given formatter. Read more

impl<H: 'static + StableDeref + DerefMut, T: 'static> Deref for RentRefCellMut<H, T>
[src]

The resulting type after dereferencing.

Dereferences the value.

impl<H: 'static + StableDeref + DerefMut, T: 'static> DerefMut for RentRefCellMut<H, T>
[src]

Mutably dereferences the value.

impl<H: 'static + StableDeref + DerefMut, T: 'static> AsRef<Self::Target> for RentRefCellMut<H, T>
[src]

Performs the conversion.

impl<H: 'static + StableDeref + DerefMut, T: 'static> AsMut<Self::Target> for RentRefCellMut<H, T>
[src]

Performs the conversion.

Auto Trait Implementations

impl<H, T> !Send for RentRefCellMut<H, T>

impl<H, T> !Sync for RentRefCellMut<H, T>