Struct rental::RentRef [] [src]

pub struct RentRef<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> where T: FixedDeref { /* fields omitted */ }

A struct representing a particular (owner, rental) pair.

All such structs share a common API, but it is merely a convention enforced by the rental macro. The capabilities of a rental struct cannot be fully described as a trait without language support for HKT (Higher-Kinded Types). What methods can be expressed in a trait are documented in the Rental and RentalMut traits.

A rental struct can implement Deref, but only if the rented type is Deref and its target does not contain the 'rental lifetime in its signature.

Methods

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> RentRef<'rental, T, B> where T: FixedDeref
[src]

Instantiate a new shared rental pair. owner is the object from which a value will be rented. The closure takes a reborrowed shared reference to the owner's Deref target, and returns the rented value. Within this closure, the special 'rental lifetime is "existential" and cannot be unified with any external lifetime. This is crucial in that it prevents any borrow of the owner from escaping from the closure other than as a return value.

As new, but the closure returns a Result with a generic error. In the event of such failure, this method will return Err with a tuple of the error itself and the owner object.

Borrows the owner.

Executes a closure on the existentially borrowed rental. The closure may return anything, including a borrow, as long as the existential 'rental lifetime does not appear in the type signature.

Trait Implementations

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> Rental for RentRef<'rental, T, B> where T: FixedDeref
[src]

This returns to you the rented value outside of an existential closure. This is unsafe because the lifetime substituted for 'rental here is a lie and does not reflect the true lifetime of the value. Only use this if you have no alternative, and think very carefully about how you're using the value to prevent it from outliving the rental struct, or inserting into it data that will not live long enough. Read more

This will produce a rental struct from component parts. Not unsafe because, if you already have the components safely, combining them in this way does not introduce any additional unsafety. Read more

This will decompose a rental struct into its component parts. This is obviously unsafe because one may drop the owner while retaining the borrow. Read more

This will consume a rental struct and return to you the owner, discarding the rented value. Read more

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> Deref for RentRef<'rental, T, B> where T: FixedDeref, RentRef<'rental, T, B>::Rental: Deref<Target=B>
[src]

The resulting type after dereferencing

The method called to dereference a value

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> AsRef<B> for RentRef<'rental, T, B> where T: FixedDeref, RentRef<'rental, T, B>: Deref<Target=B>
[src]

Performs the conversion.

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> Borrow<B> for RentRef<'rental, T, B> where T: FixedDeref, RentRef<'rental, T, B>: Deref<Target=B>
[src]

Immutably borrows from an owned value. Read more

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> PartialEq for RentRef<'rental, T, B> where T: FixedDeref, RentRef<'rental, T, B>: Deref, RentRef<'rental, T, B>::Target: PartialEq
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> Eq for RentRef<'rental, T, B> where T: FixedDeref, RentRef<'rental, T, B>: Deref, RentRef<'rental, T, B>::Target: Eq
[src]

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> PartialOrd for RentRef<'rental, T, B> where T: FixedDeref, RentRef<'rental, T, B>: Deref, RentRef<'rental, T, B>::Target: PartialOrd
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> Ord for RentRef<'rental, T, B> where T: FixedDeref, RentRef<'rental, T, B>: Deref, RentRef<'rental, T, B>::Target: Ord
[src]

This method returns an Ordering between self and other. Read more

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> Hash for RentRef<'rental, T, B> where T: FixedDeref, &'a__ B: Hash
[src]

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> Debug for RentRef<'rental, T, B> where T: FixedDeref, &'a__ B: Debug
[src]

Formats the value using the given formatter.

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> Display for RentRef<'rental, T, B> where T: FixedDeref, &'a__ B: Display
[src]

Formats the value using the given formatter.

impl<'rental, T: FixedDeref + 'rental, B: ?Sized + 'rental> Drop for RentRef<'rental, T, B> where T: FixedDeref
[src]

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