semisafe 1.0.1

Semi-safe utilities for performance-critical Rust
Documentation
//! Provides semi-safe helpers for the `Option` type.

/// Returns value inside `opt` without `None` checks in release builds.
///
/// Use this only when surrounding code guarantees that `opt` is `Some(_)`.
/// In debug builds this delegates to [`Option::unwrap`] so invariant
/// violations fail fast. In release builds, passing `None` causes undefined
/// behavior.
///
/// # Panics
///
/// Panics in debug builds if `opt` is `None`.
///
/// # Examples
///
/// ```
/// let value = semisafe::option::unwrap(Some(42));
/// assert_eq!(value, 42);
/// ```
#[inline(always)]
pub const fn unwrap<T>(opt: Option<T>) -> T {
    #[cfg(debug_assertions)]
    {
        opt.unwrap()
    }

    #[cfg(not(debug_assertions))]
    {
        unsafe { opt.unwrap_unchecked() }
    }
}