Skip to content
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

align in format! macro does not work with String as Debug #38259

Closed
ghost opened this issue Dec 9, 2016 · 1 comment
Closed

align in format! macro does not work with String as Debug #38259

ghost opened this issue Dec 9, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 9, 2016

Playground url: https://play.rust-lang.org/?gist=1ff6c43dc1da08b05ad13bc772de070e&version=nightly&backtrace=0

fn main() {
    println!("{0: <10} | {1: <10?} | {2: <10} | {3: <10}",
             "total",
             "blanks",
             "comments",
             "code");
    println!("{0: <10} | {1: <10?} | {2: <10} | {3: <10}", 0, 0, 0, 0);
    println!("{0: <10} | {1: <10} | {2: <10?} | {3: <10}", 77, 0, 3, 74);
    println!("{0: <10?} | {1: <10} | {2: <10} | {3: <10?}",
             460,
             0,
             10,
             1371);
}

Align works properly for other types.

rustc 1.15.0-nightly (daf8c1dfc 2016-12-05)
total      | "blanks" | comments   | code      
0          | 0          | 0          | 0         
77         | 0          | 3          | 74        
460        | 0          | 10         | 1371      
Program ended.

without ?

fn main() {
    println!("{0: <10} | {1: <10} | {2: <10} | {3: <10}",
             "total",
             "blanks",
             "comments",
             "code");
    println!("{0: <10} | {1: <10?} | {2: <10} | {3: <10}", 0, 0, 0, 0);
    println!("{0: <10} | {1: <10} | {2: <10?} | {3: <10}", 77, 0, 3, 74);
    println!("{0: <10?} | {1: <10} | {2: <10} | {3: <10?}",
             460,
             0,
             10,
             1371);
}
rustc 1.15.0-nightly (daf8c1dfc 2016-12-05)
total      | blanks     | comments   | code      
0          | 0          | 0          | 0         
77         | 0          | 3          | 74        
460        | 0          | 10         | 1371      
Program ended.
@sinkuu
Copy link
Contributor

sinkuu commented Feb 20, 2017

This issue is a duplication of #30164.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants