Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: simplify watchmap traversal #98

Merged
merged 8 commits into from
Jan 9, 2025
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