-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add number formatting #15
Conversation
'x' | 'X' => self.write_str("0x").unwrap(), | ||
_ => { | ||
let mut msg = String::new(); | ||
write!(msg, "alternate ('#') cannot be used with type {:?}", ty).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when I first wrote this lib I didn't know about format!()
. Please use that instead here. You can even get rid of msg
variable alltogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, I'll handle it in a separate commit... maybe (who really cares, haha).
Thanks for the PR!
|
||
pub use types::{Result, FmtError, Alignment, Sign}; | ||
pub use fmtstr::strfmt_map; | ||
pub use formatter::Formatter; | ||
|
||
// u128 & i128 unstable (see https://github.com/rust-lang/rust/issues/35118) | ||
fmtint!(u8 i8 u16 i16 u32 i32 u64 i64 usize isize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoa! I didn't know this was possible, I thought they would have to each be their own line. Good work!
Looks good, from travis run:
|
No problem 👍 |
I just publised |
As discussed in #13.
I ended up splitting it into two macros, one for integers and one for floats. I also spilt the tests into three macros for unsigned and signed integers, and floats.
Let me know if you have any comments 👍