Skip to content

Commit c0b7e76

Browse files
committedOct 17, 2019
example for padding any format
1 parent 4e6efe4 commit c0b7e76

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎src/liballoc/fmt.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@
136136
//!
137137
//! Note that alignment may not be implemented by some types. In particular, it
138138
//! is not generally implemented for the `Debug` trait. A good way to ensure
139-
//! padding is applied is to format your input, then use this resulting string
140-
//! to pad your output.
139+
//! padding is applied is to format your input, then pad this resulting string
140+
//! to obtain your output:
141+
//!
142+
//! ```
143+
//! println!("Hello {:^15}!", format!("{:?}", Some("hi"))); // => "Hello Some("hi") !"
144+
//! ```
141145
//!
142146
//! ## Sign/`#`/`0`
143147
//!

0 commit comments

Comments
 (0)
Please sign in to comment.