Struct dangerous_option::DangerousOption
[−]
[src]
pub struct DangerousOption<T, H: ExceptionHandler = DefaultExceptionHandler>(_, _);
Represents a value that might be uninitialized, but most probably isn't. It provides convenient
access to the value via Deref
while checking whether the value is actually initialized.
When deref of initialized value is attempted, the ExceptionHandler is called. This will lead to aborting of the task.
Methods
impl<T, H: ExceptionHandler> DangerousOption<T, H>
[src]
fn new(val: T) -> Self
[src]
Creates valid value.
fn new_uninitialized() -> Self
[src]
Creates uninitialized value.
fn take_unchecked(this: &mut Self) -> T
[src]
Takes out the value, failing if it's not there. After call to this function, the value is uninitialized.
fn take_checked(this: &mut Self) -> Option<T>
[src]
Tries to take out the value. After call to this function, the value is uninitialized.
fn try(this: &Self) -> Option<&T>
[src]
Non-panicking version of deref, which returns None
, if value is uninitiaized.
fn try_mut(this: &mut Self) -> Option<&mut T>
[src]
Non-panicking version of deref_mut, which returns None
, if value is uninitiaized.
fn put(this: &mut Self, val: T) -> Option<T>
[src]
Puts the new value in place of old, optionally returning old value.
Trait Implementations
impl<T: Debug, H: Debug + ExceptionHandler> Debug for DangerousOption<T, H>
[src]
impl<T, H: ExceptionHandler> Deref for DangerousOption<T, H>
[src]
type Target = T
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
Dereferences the value.
impl<T, H: ExceptionHandler> DerefMut for DangerousOption<T, H>
[src]
impl<T> Clone for DangerousOption<T> where
T: Clone,
[src]
T: Clone,