[][src]Struct rental::examples::SimpleRefMap

pub struct SimpleRefMap<T: 'static> { /* fields omitted */ }

Identical to SimpleRef, but with the map_suffix flag enabled. This will allow the type of the suffix to be changed by mapping it to another instantiation of the same struct with the different type param. See the map, try_map, and try_map_or_drop methods.

Methods

impl<T: 'static> SimpleRefMap<T>[src]

pub fn new<__Firef>(head: Box<i32>, iref: __Firef) -> Self where
    __Firef: for<'head> FnOnce(&'head i32) -> &'head T, 
[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 i32) -> Result<&'head T, __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 i32) -> Result<&'head T, __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::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(&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, f: __F) -> __R where
    __F: for<'iref, 'head> FnOnce(&'iref &'head T) -> __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 rentail lifetimes of the struct.

pub fn rent_mut<__F, __R>(&mut self, f: __F) -> __R where
    __F: for<'iref, 'head> FnOnce(&'iref mut &'head T) -> __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 rentail lifetimes of the struct.

pub fn ref_rent<__F, __R>(&self, f: __F) -> &__R where
    __F: for<'iref, 'head> FnOnce(&'iref &'head T) -> &'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, f: __F) -> Option<&__R> where
    __F: for<'iref, 'head> FnOnce(&'iref &'head T) -> 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, f: __F) -> Result<&__R, __E> where
    __F: for<'iref, 'head> FnOnce(&'iref &'head T) -> 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>(&mut self, f: __F) -> &mut __R where
    __F: for<'iref, 'head> FnOnce(&'iref mut &'head T) -> &'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>(&mut self, f: __F) -> Option<&mut __R> where
    __F: for<'iref, 'head> FnOnce(&'iref mut &'head T) -> 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>(
    &mut self,
    f: __F
) -> Result<&mut __R, __E> where
    __F: for<'iref, 'head> FnOnce(&'iref mut &'head T) -> 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) -> Box<i32>[src]

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

impl<T: 'static> SimpleRefMap<T>[src]

pub fn head(&self) -> &<Box<i32> as Deref>::Target[src]

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

pub fn rent_all<__F, __R>(&self, f: __F) -> __R where
    __F: for<'head, 'iref> FnOnce(SimpleRefMap_Borrow<'head, 'iref, T>) -> __R,
    __R: , 
[src]

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.

pub fn ref_rent_all<__F, __R>(&self, f: __F) -> &__R where
    __F: for<'head, 'iref> FnOnce(SimpleRefMap_Borrow<'head, 'iref, T>) -> &'iref __R,
    __R: ?Sized
[src]

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.

pub fn maybe_ref_rent_all<__F, __R>(&self, f: __F) -> Option<&__R> where
    __F: for<'head, 'iref> FnOnce(SimpleRefMap_Borrow<'head, 'iref, T>) -> Option<&'iref __R>,
    __R: ?Sized
[src]

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

pub fn try_ref_rent_all<__F, __R, __E>(&self, f: __F) -> Result<&__R, __E> where
    __F: for<'head, 'iref> FnOnce(SimpleRefMap_Borrow<'head, 'iref, T>) -> Result<&'iref __R, __E>,
    __R: ?Sized
[src]

Try to return a shared reference from shared borrows of the fields of the struct, or an error on failure.

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.

pub fn rent_all_mut<__F, __R>(&mut self, f: __F) -> __R where
    __F: for<'head, 'iref> FnOnce(SimpleRefMap_BorrowMut<'head, 'iref, T>) -> __R,
    __R: , 
[src]

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.

pub fn ref_rent_all_mut<__F, __R>(&mut self, f: __F) -> &mut __R where
    __F: for<'head, 'iref> FnOnce(SimpleRefMap_BorrowMut<'head, 'iref, T>) -> &'iref mut __R,
    __R: ?Sized
[src]

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.

pub fn maybe_ref_rent_all_mut<__F, __R>(&mut self, f: __F) -> Option<&mut __R> where
    __F: for<'head, 'iref> FnOnce(SimpleRefMap_BorrowMut<'head, 'iref, T>) -> Option<&'iref mut __R>,
    __R: ?Sized
[src]

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

pub fn try_ref_rent_all_mut<__F, __R, __E>(
    &mut self,
    f: __F
) -> Result<&mut __R, __E> where
    __F: for<'head, 'iref> FnOnce(SimpleRefMap_BorrowMut<'head, 'iref, T>) -> Result<&'iref mut __R, __E>,
    __R: ?Sized
[src]

Try to return a mutable reference from shared borrows of the prefix fields and a mutable borrow of the suffix field of the struct, or an error on failure.

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.

impl<T: 'static> SimpleRefMap<T>[src]

pub fn map<__U: 'static, __F>(self, __f: __F) -> SimpleRefMap<__U> where
    __F: for<'iref, 'head> FnOnce(&'head T) -> &'head __U, 
[src]

Maps the suffix field of the rental struct to a different type.

Consumes the rental struct and applies the closure to the suffix field. A new rental struct is then constructed with the original prefix and new suffix.

pub fn try_map<__U: 'static, __F, __E>(
    self,
    __f: __F
) -> RentalResult<SimpleRefMap<__U>, __E, Box<i32>> where
    __F: for<'iref, 'head> FnOnce(&'head T) -> Result<&'head __U, __E>, 
[src]

Try to map the suffix field of the rental struct to a different type.

As map, but the closure may fail. Upon failure, the tail is dropped, and the error is returned to you along with the head.

pub fn try_map_or_drop<__U: 'static, __F, __E>(
    self,
    __f: __F
) -> Result<SimpleRefMap<__U>, __E> where
    __F: for<'iref, 'head> FnOnce(&'head T) -> Result<&'head __U, __E>, 
[src]

Try to map the suffix field of the rental struct to a different type.

As map, but the closure may fail. Upon failure, the struct is dropped and the error is returned.

Auto Trait Implementations

impl<T> Send for SimpleRefMap<T> where
    T: Sync

impl<T> Sync for SimpleRefMap<T> where
    T: Sync

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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