pub trait Unwrap {
type Output;
// Required methods
fn unwrap(self) -> Self::Output;
fn has_value(&self) -> bool;
}Expand description
Indicate that a type is a wrapper of a value and can be unwrapped into it.
Only available if the unwrap feature is enabled (enabled by default).
Unwrap is implemented by default for four types:
Option<T>Result<T, E>UnitTuple<T0, T1, ... Tn>if all typesT0,T1, …TnimplementUnwrap.
Implement Unwrap for your own wrapper types so that a Tuple containing your wrappers can be unwrap().
Required Associated Types§
Required Methods§
sourcefn unwrap(self) -> Self::Output
fn unwrap(self) -> Self::Output
Get the contained value.
Because this function may panic, its use is generally discouraged. Instead,
use unwrap_or_default() or
try_unwrap().
§Panic
Panic if self does not contain a value.
§Example
use tuplez::*;
let tup = tuple!(Some(1), Ok::<f32, ()>(3.14), Some("hello"));
assert_eq!(tup.unwrap(), tuple!(1, 3.14, "hello"));sourcefn has_value(&self) -> bool
fn has_value(&self) -> bool
Check if self contains a value.
Soundess requirement: When has_value() returns true, unwrap() cannot panic.