SafeUnwrap

Trait SafeUnwrap 

Source
pub trait SafeUnwrap<T> {
    // Required methods
    fn safe_unwrap(self, fallback: T) -> T;
    fn safe_unwrap_or_log(self, context: &str, fallback: T) -> T;
}
Expand description

Lightweight unwrap replacement that doesn’t panic in release builds

Required Methods§

Source

fn safe_unwrap(self, fallback: T) -> T

Unwrap with fallback value in release builds

Source

fn safe_unwrap_or_log(self, context: &str, fallback: T) -> T

Unwrap with error context but no panic in release

Implementations on Foreign Types§

Source§

impl<T> SafeUnwrap<T> for Option<T>

Source§

fn safe_unwrap(self, fallback: T) -> T

Source§

fn safe_unwrap_or_log(self, context: &str, fallback: T) -> T

Source§

impl<T, E: Debug> SafeUnwrap<T> for Result<T, E>

Source§

fn safe_unwrap(self, _fallback: T) -> T

Source§

fn safe_unwrap_or_log(self, context: &str, fallback: T) -> T

Implementors§