diff options
Diffstat (limited to 'src/libcore/fmt/num.rs')
| -rw-r--r-- | src/libcore/fmt/num.rs | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 9cfa7bec22f..13cfcacf8da 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -100,13 +100,13 @@ macro_rules! radix { } } -radix!(Binary, 2, "0b", x @ 0 ... 2 => b'0' + x) -radix!(Octal, 8, "0o", x @ 0 ... 7 => b'0' + x) -radix!(Decimal, 10, "", x @ 0 ... 9 => b'0' + x) -radix!(LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x, - x @ 10 ... 15 => b'a' + (x - 10)) -radix!(UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x, - x @ 10 ... 15 => b'A' + (x - 10)) +radix! { Binary, 2, "0b", x @ 0 ... 2 => b'0' + x } +radix! { Octal, 8, "0o", x @ 0 ... 7 => b'0' + x } +radix! { Decimal, 10, "", x @ 0 ... 9 => b'0' + x } +radix! { LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x, + x @ 10 ... 15 => b'a' + (x - 10) } +radix! { UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x, + x @ 10 ... 15 => b'A' + (x - 10) } /// A radix with in the range of `2..36`. #[deriving(Clone, PartialEq)] @@ -174,23 +174,23 @@ macro_rules! int_base { } macro_rules! integer { ($Int:ident, $Uint:ident) => { - int_base!(Show for $Int as $Int -> Decimal) - int_base!(Binary for $Int as $Uint -> Binary) - int_base!(Octal for $Int as $Uint -> Octal) - int_base!(LowerHex for $Int as $Uint -> LowerHex) - int_base!(UpperHex for $Int as $Uint -> UpperHex) - radix_fmt!($Int as $Int, fmt_int) - - int_base!(Show for $Uint as $Uint -> Decimal) - int_base!(Binary for $Uint as $Uint -> Binary) - int_base!(Octal for $Uint as $Uint -> Octal) - int_base!(LowerHex for $Uint as $Uint -> LowerHex) - int_base!(UpperHex for $Uint as $Uint -> UpperHex) - radix_fmt!($Uint as $Uint, fmt_int) + int_base! { Show for $Int as $Int -> Decimal } + int_base! { Binary for $Int as $Uint -> Binary } + int_base! { Octal for $Int as $Uint -> Octal } + int_base! { LowerHex for $Int as $Uint -> LowerHex } + int_base! { UpperHex for $Int as $Uint -> UpperHex } + radix_fmt! { $Int as $Int, fmt_int } + + int_base! { Show for $Uint as $Uint -> Decimal } + int_base! { Binary for $Uint as $Uint -> Binary } + int_base! { Octal for $Uint as $Uint -> Octal } + int_base! { LowerHex for $Uint as $Uint -> LowerHex } + int_base! { UpperHex for $Uint as $Uint -> UpperHex } + radix_fmt! { $Uint as $Uint, fmt_int } } } -integer!(int, uint) -integer!(i8, u8) -integer!(i16, u16) -integer!(i32, u32) -integer!(i64, u64) +integer! { int, uint } +integer! { i8, u8 } +integer! { i16, u16 } +integer! { i32, u32 } +integer! { i64, u64 } |
