Skip to content

Commit

Permalink
refactor: simplify watchmap traversal (#98)
Browse files Browse the repository at this point in the history
* refactor: use NonZeroU32 for literals
* refactor: watch traversal
  • Loading branch information
baszalmstra authored Jan 9, 2025
1 parent 67d8e3b commit 7b5aa29
Show file tree
Hide file tree
Showing 5 changed files with 451 additions and 395 deletions.
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

0 comments on commit 7b5aa29

Please sign in to comment.