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.
Methods
impl<'marker, 't, T> Allocation<'marker, 't, T> where
T: 't + Sized,
[src]
T: 't + Sized,
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> Deref for Allocation<'marker, 't, T> where
T: 't,
[src]
T: 't,
type Target = T
The resulting type after dereferencing.
fn deref(&self) -> &T
[src]
Dereferences the value.
impl<'marker, 't, T: ?Sized> DerefMut for Allocation<'marker, 't, T> where
T: 't,
[src]
T: 't,
impl<'marker, 't, T: ?Sized> Drop for Allocation<'marker, 't, T> where
T: 't,
[src]
T: 't,
impl<'marker, 't, T: ?Sized> Debug for Allocation<'marker, 't, T> where
T: 't + Debug,
[src]
T: 't + Debug,
Auto Trait Implementations
impl<'marker, 't, T: ?Sized> Send for Allocation<'marker, 't, T> where
T: Send,
T: Send,
impl<'marker, 't, T: ?Sized> Sync for Allocation<'marker, 't, T> where
T: Sync,
T: Sync,