Struct scratchpad::Allocation [−][src]
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]
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> Debug for Allocation<'marker, 't, T> where
T: 't + Debug,
[src]
T: 't + Debug,
impl<'marker, 't, T: ?Sized> Deref for Allocation<'marker, 't, T> where
T: 't,
[src]
T: 't,
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,
Auto Trait Implementations
impl<'marker, 't, T: ?Sized> RefUnwindSafe for Allocation<'marker, 't, T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<'marker, 't, T: ?Sized> Send for Allocation<'marker, 't, T> where
T: Send,
[src]
T: Send,
impl<'marker, 't, T: ?Sized> Sync for Allocation<'marker, 't, T> where
T: Sync,
[src]
T: Sync,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,