Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ pub mod frozen_copy_map;
pub mod id;
pub mod mapping;
pub mod small_vec;
mod unwrap_unchecked;

pub use unwrap_unchecked::debug_expect_unchecked;
13 changes: 13 additions & 0 deletions src/internal/unwrap_unchecked.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// An unsafe method that unwraps an option without checking if it is `None` in
/// release mode but does check the value in debug mode.
#[track_caller]
pub unsafe fn debug_expect_unchecked<T>(opt: Option<T>, _msg: &str) -> T {
#[cfg(debug_assertions)]
{
opt.expect(_msg)
}
#[cfg(not(debug_assertions))]
{
opt.unwrap_unchecked()
}
}
Loading
Loading