Struct scratchpad::Allocation[][src]

pub struct Allocation<'marker, 't, T: ?Sized> where
    T: 't, 
{ /* fields omitted */ }

Scratchpad Marker allocation.

Markers implement the Deref and DerefMut traits, allowing the data to be dereferenced explicitly using the unary * operator (e.g. *allocation) or implicitly by the compiler under various circumstances.

An allocation is statically bound to the lifetime of the Marker from which it is allocated, ensuring that no dangling references can be left when the Marker is dropped.

Implementations

impl<'marker, 't, T> Allocation<'marker, 't, T> where
    T: 't + Sized
[src]

pub fn unwrap(self) -> T[src]

Moves the value out of the Allocation.

Note that this is only implemented for Sized value types.

Examples

use scratchpad::Scratchpad;

let x = {
    let scratchpad = Scratchpad::<[u64; 1], [usize; 1]>::new(
        [0],
        [0],
    );
    let marker = scratchpad.mark_front().unwrap();
    let allocation = marker.allocate(3.14159).unwrap();

    allocation.unwrap()
};

// Value was moved out of the allocation, so it can now outlive the
// scratchpad in which it was initially created.
assert_eq!(x, 3.14159);

Trait Implementations

impl<'marker, 't, T: ?Sized> Debug for Allocation<'marker, 't, T> where
    T: 't + Debug
[src]

impl<'marker, 't, T: ?Sized> Deref for Allocation<'marker, 't, T> where
    T: 't, 
[src]

type Target = T

The resulting type after dereferencing.

impl<'marker, 't, T: ?Sized> DerefMut for Allocation<'marker, 't, T> where
    T: 't, 
[src]

impl<'marker, 't, T: ?Sized> Drop for Allocation<'marker, 't, T> where
    T: 't, 
[src]

Auto Trait Implementations

impl<'marker, 't, T: ?Sized> RefUnwindSafe for Allocation<'marker, 't, T> where
    T: RefUnwindSafe
[src]

impl<'marker, 't, T: ?Sized> Send for Allocation<'marker, 't, T> where
    T: Send
[src]

impl<'marker, 't, T: ?Sized> Sync for Allocation<'marker, 't, T> where
    T: Sync
[src]

impl<'marker, 't, T: ?Sized> Unpin for Allocation<'marker, 't, T>[src]

impl<'marker, 't, T> !UnwindSafe for Allocation<'marker, 't, T>[src]

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.