Skip to content

Commit 7b5aa29

Browse files
authored
refactor: simplify watchmap traversal (#98)
* refactor: use NonZeroU32 for literals * refactor: watch traversal
1 parent 67d8e3b commit 7b5aa29

File tree

5 files changed

+451
-395
lines changed

5 files changed

+451
-395
lines changed

src/internal/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ pub mod frozen_copy_map;
33
pub mod id;
44
pub mod mapping;
55
pub mod small_vec;
6+
mod unwrap_unchecked;
7+
8+
pub use unwrap_unchecked::debug_expect_unchecked;

src/internal/unwrap_unchecked.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// An unsafe method that unwraps an option without checking if it is `None` in
2+
/// release mode but does check the value in debug mode.
3+
#[track_caller]
4+
pub unsafe fn debug_expect_unchecked<T>(opt: Option<T>, _msg: &str) -> T {
5+
#[cfg(debug_assertions)]
6+
{
7+
opt.expect(_msg)
8+
}
9+
#[cfg(not(debug_assertions))]
10+
{
11+
opt.unwrap_unchecked()
12+
}
13+
}

0 commit comments

Comments
 (0)