From 19c99634c385ddbcee2ddbb3722b5fa4987fd1d8 Mon Sep 17 00:00:00 2001 From: Andreas Longva Date: Thu, 24 Nov 2022 09:19:25 +0100 Subject: [PATCH] Add U0, U1, ... dimension constants This allows us to simply write U4 in place of U4::name() or Const::<4>, like we used to be able to before const generics. --- src/base/dimension.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/base/dimension.rs b/src/base/dimension.rs index 3d1de1ff..fef44645 100644 --- a/src/base/dimension.rs +++ b/src/base/dimension.rs @@ -310,6 +310,11 @@ macro_rules! from_to_typenum ( } impl IsNotStaticOne for $D { } + + /// The constant dimension + #[doc = stringify!($VAL)] + /// . + pub const $D: $D = Const::<$VAL>; )*} ); @@ -323,3 +328,7 @@ from_to_typenum!( U111, 111; U112, 112; U113, 113; U114, 114; U115, 115; U116, 116; U117, 117; U118, 118; U119, 119; U120, 120; U121, 121; U122, 122; U123, 123; U124, 124; U125, 125; U126, 126; U127, 127 ); + +/// The constant dimension 1. +// Note: We add U1 separately since it's not covered by the from_to_typenum! macro. +pub const U1: U1 = Const::<1>;