Skip to content

Commit 50df06d

Browse files
committed
Add new_unchecked function without check
1 parent 31b5d11 commit 50df06d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ macro_rules! implement_common {
118118
$name(value)
119119
}
120120

121+
/// Creates a new variable without checking if the variable is representable by this type.
122+
///
123+
/// # Safety
124+
/// The value must be representable by this type.
125+
pub const unsafe fn new_unchecked(value: $type) -> $name {
126+
$name(value)
127+
}
128+
121129
/// Wrapping (modular) subtraction. Computes `self - other`,
122130
/// wrapping around at the boundary of the type.
123131
///

0 commit comments

Comments
 (0)