Expand description
This library provides alternatives to the standard .unwrap
* methods on Result
and Option
that don’t require Debug
to be implemented on the unexpected variant.
§Example
Given
struct T;
let none = Option::<T>::None;
let ok = Result::<T, T>::Ok(T);
let err = Result::<T, T>::Err(T);
, the following std
methods are unavailable:
ⓘ
none.unwrap_none(); // Some(T) isn't Debug.
ⓘ
ok.unwrap(); // Err(T) isn't Debug.
ⓘ
err.unwrap_err(); // Ok(T) isn't Debug.
The methods in this library can be used in this situation (e.g. when working with generics), but provide less information:
Additionally given
use debugless_unwrap::*;
, the following work like their debugless_
-less equivalents:
none.debugless_unwrap_none();
ok.debugless_unwrap();
err.debugless_unwrap_err();
Traits§
- Provides
.debugless_unwrap()
onResult
. - Provides
.debugless_unwrap_err()
onResult
. - Provides
.debugless_unwrap_none()
onOption
.