From 41a395c74a3da70b89d9324bba2a00c2339dd326 Mon Sep 17 00:00:00 2001 From: Finn Behrens Date: Mon, 26 Jun 2023 11:19:31 +0200 Subject: [PATCH] Add new_unchecked function without check --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index de735d9..43698ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -118,6 +118,14 @@ macro_rules! implement_common { $name(value) } + /// Creates a new instance without checking if the value is representable by this type. + /// + /// # Safety + /// The value must be representable by this type. + pub const unsafe fn new_unchecked(value: $type) -> $name { + $name(value) + } + /// Wrapping (modular) subtraction. Computes `self - other`, /// wrapping around at the boundary of the type. ///