Struct rental::examples::RentMut [] [src]

pub struct RentMut<T: 'static, U: 'static> { /* fields omitted */ }

A simple example that can store an owner and a mutable reference in the same struct.

let mut r = RentMut::new(Box::new(5), |i| &mut *i);
*r = 12;
assert_eq!(12, r.rent(|iref| **iref));

Methods

impl<T: 'static, U: 'static> RentMut<T, U>
[src]

[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.

[src]

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.

[src]

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.

[src]

Return direct shared borrows of the fields of the struct.

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

[src]

Return a direct mutable borrow of the suffix of the struct.

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

[src]

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.

[src]

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.

[src]

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.

[src]

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.

[src]

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.

[src]

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.

[src]

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.

[src]

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.

[src]

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

Trait Implementations

impl<T: 'static, U: 'static> Deref for RentMut<T, U>
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl<T: 'static, U: 'static> DerefMut for RentMut<T, U>
[src]

[src]

Mutably dereferences the value.

impl<T: 'static, U: 'static> AsRef<Self::Target> for RentMut<T, U>
[src]

[src]

Performs the conversion.

impl<T: 'static, U: 'static> AsMut<Self::Target> for RentMut<T, U>
[src]

[src]

Performs the conversion.