Struct rental::examples::RentRefMap [] [src]

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

An example that borrows off of another rental struct.

let r = RentRef::new(Box::new(5), |i| &*i);
let rm = RentRefMap::new(Box::new(r), |r| &**r.suffix);
assert_eq!(*rm, rm.rent(|iref| **iref));

Methods

impl<T: 'static, U: 'static, V: 'static> RentRefMap<T, U, V>
[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 the result is an error, execution is short-circuited and the error is returned to you, along with the original head value.

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.

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.

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.

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.

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.

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

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

Return a shared reference to the head field of the struct.

Execute a closure on shared borrows of the fields of the struct.

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

Return a shared reference from shared borrows of the fields of the struct.

This is a subtle variation of rent_all 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.

Execute a closure on shared borrows of the prefix fields and a mutable borrow of the suffix field of the struct.

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

Return a mutable reference from shared borrows of the prefix fields and a mutable borrow of the suffix field of the struct.

This is a subtle variation of rent_all_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.

Trait Implementations

impl<T: 'static, U: 'static, V: 'static> Drop for RentRefMap<T, U, V>
[src]

A method called when the value goes out of scope. Read more

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

The resulting type after dereferencing

The method called to dereference a value

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

Performs the conversion.