We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5b8ac3d commit 36f3dfcCopy full SHA for 36f3dfc
core/src/num/niche_types.rs
@@ -32,9 +32,15 @@ macro_rules! define_valid_range_type {
32
};
33
34
impl $name {
35
+ /// Constructs an instance of this type from the underlying integer
36
+ /// primitive without checking whether its zero.
37
+ ///
38
+ /// # Safety
39
+ /// Immediate language UB if `val == 0`, as it violates the validity
40
+ /// invariant of this type.
41
#[inline]
42
pub const unsafe fn new_unchecked(val: $int) -> Self {
- // SAFETY: same precondition
43
+ // SAFETY: Caller promised that `val` is non-zero.
44
unsafe { $name(val) }
45
}
46
0 commit comments