Crate unwrap_unreachable

Crate unwrap_unreachable 

Source
Expand description

§Unwrap unreachable

Provides Option::unreachable() and Result::unreachable() methods by providing an UnwrapUnreachable extension trait.

§Usage

// Make sure you import the trait. Otherwise, these functions will not be available.
use unwrap_unreachable::UnwrapUnreachable;

// This regex is known to compile at compile time… so it will not panic
// at execution
static H5AI_RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"powered by h5ai (v\d+.\d+.\d+)").unreachable());

// unreachable() here is ok since we know this should not return anything
// else than Ok(httpdir) if it does it should panic as the test fail.
let httpdir = prepare_httpdir().filter_by_name("debian").unreachable();

Traits§

UnwrapUnreachable
Provide the unreachable() method on Option and Result types.