[][src]Struct rental::examples::SimpleMutDeref

pub struct SimpleMutDeref { /* fields omitted */ }

Identical to SimpleMut, but with the deref_mut_suffix flag enabled. This will provide a DerefMut impl for the struct, which will in turn deref the suffix.Notice that this flag also removes the self param from all methods, replacing it with an explicit param. This prevents any rental methods from blocking deref.

Implementations

impl SimpleMutDeref[src]

pub fn new<__Firef>(head: Box<i32>, iref: __Firef) -> Self where
    __Firef: for<'head> FnOnce(&'head mut i32) -> &'head mut i32
[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.

pub fn try_new<__Firef, __E>(
    head: Box<i32>,
    iref: __Firef
) -> RentalResult<Self, __E, Box<i32>> where
    __Firef: for<'head> FnOnce(&'head mut i32) -> Result<&'head mut i32, __E>, 
[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.

pub fn try_new_or_drop<__Firef, __E>(
    head: Box<i32>,
    iref: __Firef
) -> Result<Self, __E> where
    __Firef: for<'head> FnOnce(&'head mut i32) -> Result<&'head mut i32, __E>, 
[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.

pub unsafe fn all_erased(_self: &Self) -> Self::Borrow[src]

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.

pub unsafe fn all_mut_erased(_self: &mut Self) -> Self::BorrowMut[src]

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.

pub fn rent<__F, __R>(_self: &Self, f: __F) -> __R where
    __F: for<'iref, 'head> FnOnce(&'iref &'head mut i32) -> __R,
    __R: , 
[src]

Execute a closure on the shared suffix of the struct.

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

pub fn rent_mut<__F, __R>(_self: &mut Self, f: __F) -> __R where
    __F: for<'iref, 'head> FnOnce(&'iref mut &'head mut i32) -> __R,
    __R: , 
[src]

Execute a closure on the mutable suffix of the struct.

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

pub fn ref_rent<__F, __R>(_self: &Self, f: __F) -> &__R where
    __F: for<'iref, 'head> FnOnce(&'iref &'head mut i32) -> &'iref __R,
    __R: ?Sized
[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.

pub fn maybe_ref_rent<__F, __R>(_self: &Self, f: __F) -> Option<&__R> where
    __F: for<'iref, 'head> FnOnce(&'iref &'head mut i32) -> Option<&'iref __R>,
    __R: ?Sized
[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.

pub fn try_ref_rent<__F, __R, __E>(_self: &Self, f: __F) -> Result<&__R, __E> where
    __F: for<'iref, 'head> FnOnce(&'iref &'head mut i32) -> Result<&'iref __R, __E>,
    __R: ?Sized
[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.

pub fn ref_rent_mut<__F, __R>(_self: &mut Self, f: __F) -> &mut __R where
    __F: for<'iref, 'head> FnOnce(&'iref mut &'head mut i32) -> &'iref mut __R,
    __R: ?Sized
[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.

pub fn maybe_ref_rent_mut<__F, __R>(
    _self: &mut Self,
    f: __F
) -> Option<&mut __R> where
    __F: for<'iref, 'head> FnOnce(&'iref mut &'head mut i32) -> Option<&'iref mut __R>,
    __R: ?Sized
[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.

pub fn try_ref_rent_mut<__F, __R, __E>(
    _self: &mut Self,
    f: __F
) -> Result<&mut __R, __E> where
    __F: for<'iref, 'head> FnOnce(&'iref mut &'head mut i32) -> Result<&'iref mut __R, __E>,
    __R: ?Sized
[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.

pub fn into_head(_self: Self) -> Box<i32>[src]

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

Trait Implementations

impl AsMut<<SimpleMutDeref as Deref>::Target> for SimpleMutDeref[src]

impl AsRef<<SimpleMutDeref as Deref>::Target> for SimpleMutDeref[src]

impl Deref for SimpleMutDeref[src]

type Target = <&'static mut i32 as Deref>::Target

The resulting type after dereferencing.

impl DerefMut for SimpleMutDeref[src]

Auto Trait Implementations

impl RefUnwindSafe for SimpleMutDeref

impl Send for SimpleMutDeref

impl Sync for SimpleMutDeref

impl Unpin for SimpleMutDeref

impl !UnwindSafe for SimpleMutDeref

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.