Skip to content

Commit acfd456

Browse files
committed
Reject u16::MAX in OneBased::from_zero_based
`Option::<T>::unwrap` is not stable on the MSRV so we need to use an assertion instead.
1 parent f7f7421 commit acfd456

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ impl OneBased {
3434
}
3535

3636
pub const fn from_zero_based(n: u16) -> Self {
37-
OneBased(NonZeroU16::new(n).unwrap())
37+
assert!(n < u16::MAX);
38+
Self(unsafe { NonZeroU16::new_unchecked(n + 1) })
3839
}
3940

4041
pub const fn get(self) -> u16 {

0 commit comments

Comments
 (0)