Skip to content

Cleanup in the core::fmt::num module #22916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions src/libcore/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct LowerHex;

/// A hexadecimal (base 16) radix, formatted with upper-case characters
#[derive(Clone, PartialEq)]
pub struct UpperHex;
struct UpperHex;

macro_rules! radix {
($T:ident, $base:expr, $prefix:expr, $($x:pat => $conv:expr),+) => {
Expand Down Expand Up @@ -156,7 +156,7 @@ pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {
}

macro_rules! radix_fmt {
($T:ty as $U:ty, $fmt:ident, $S:expr) => {
($T:ty as $U:ty, $fmt:ident) => {
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for RadixFmt<$T, Radix> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand All @@ -182,8 +182,8 @@ macro_rules! int_base {
}
}

macro_rules! show {
($T:ident with $S:expr) => {
macro_rules! debug {
($T:ident) => {
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for $T {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand All @@ -194,27 +194,24 @@ macro_rules! show {
}
macro_rules! integer {
($Int:ident, $Uint:ident) => {
integer! { $Int, $Uint, stringify!($Int), stringify!($Uint) }
};
($Int:ident, $Uint:ident, $SI:expr, $SU:expr) => {
int_base! { Display 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, $SI }
show! { $Int with $SI }
radix_fmt! { $Int as $Int, fmt_int }
debug! { $Int }

int_base! { Display 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, $SU }
show! { $Uint with $SU }
radix_fmt! { $Uint as $Uint, fmt_int }
debug! { $Uint }
}
}
integer! { isize, usize, "i", "u" }
integer! { isize, usize }
integer! { i8, u8 }
integer! { i16, u16 }
integer! { i32, u32 }
Expand Down