macro_rules! polymorphic_constant {
($(#[$attr:meta])* ($($vis:tt)*) const $name:ident : $( $numeric_type:ident )|* = $lit:literal; $($nextLine:tt)*) => { ... };
($(#[$attr:meta])* const $($t:tt)*) => { ... };
($(#[$attr:meta])* pub const $($t:tt)*) => { ... };
($(#[$attr:meta])* pub ($($vis:tt)+) const $($t:tt)*) => { ... };
() => { ... };
}
Expand description
Define one or more polymorphic numerical constants. A constant X of value 10, available in i32 and u32 will read:
polymorphic_constant! {
const X: i32 | u32 = 10;
}
and be used like:
let x_i32 = X.i32;