diff --git a/src/lib.rs b/src/lib.rs index 46aa0b2..f4383cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -142,6 +142,14 @@ impl Fix { } } + /// Like `Self::new`, but creates numbers in the constant context. + pub const fn constant(bits: Bits) -> Self { + Fix { + bits, + marker: PhantomData, + } + } + /// Converts to another _Exp_. /// /// # Examples @@ -845,4 +853,9 @@ mod tests { let end = Milli::new(u128::MAX); assert_eq!(start.abs_diff(&end), end); } + + #[test] + fn constant() { + assert_eq!(Kilo::constant(69u64), Kilo::new(69u64)); + } }