Skip to content

Typo in Formatting "Learn Rust By Example" section #1434

Closed
rust-lang/rust
#85205
@silverAndroid

Description

@silverAndroid

What needs to be fixed?

One of the code samples is written as

// You can pad numbers with extra zeroes. This will output "000001".
println!("{number:>0width$}", number=1, width=6);

This won't actually pad the string with zeroes, it'll actually output " 1".

Page(s) Affected

https://doc.rust-lang.org/stable/rust-by-example/hello/print.html

Suggested Improvement

Update the code snippet to

// You can pad numbers with extra zeroes. This will output "000001".
println!("{number:0>width$}", number=1, width=6);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions