Trait rental::Rental [] [src]

pub unsafe trait Rental {
    type Owner: FixedDeref;
    type Rental;
    unsafe fn rental(&self) -> &Self::Rental;
    fn from_parts(_: Self::Owner, _: Self::Rental) -> Self;
    unsafe fn into_parts(self) -> (Self::Owner, Self::Rental);
    fn into_owner(self) -> Self::Owner;
}

This trait is implemented for all rental structs.

It contains within everything that is possible to express without HKT. The most important methods can't be expressed here, but can be seen on the predefined RentRef and RentMut structs.

Associated Types

Required Methods

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.

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.

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

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

Implementors