about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-10-17 23:00:46 +0200
committerRalf Jung <post@ralfj.de>2019-10-17 23:02:09 +0200
commitc0b7e769a0f76a76fc5d239d886e5b8a69648b10 (patch)
treec50726fb89ac3b8d93dffb71c86de718882dc987 /src/liballoc
parent4e6efe48110a5e09ee87b0aa8cea31d511bb5708 (diff)
downloadrust-c0b7e769a0f76a76fc5d239d886e5b8a69648b10.tar.gz
rust-c0b7e769a0f76a76fc5d239d886e5b8a69648b10.zip
example for padding any format
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/fmt.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs
index 4d3523da7fc..cbfc55233a1 100644
--- a/src/liballoc/fmt.rs
+++ b/src/liballoc/fmt.rs
@@ -136,8 +136,12 @@
 //!
 //! Note that alignment may not be implemented by some types. In particular, it
 //! is not generally implemented for the `Debug` trait.  A good way to ensure
-//! padding is applied is to format your input, then use this resulting string
-//! to pad your output.
+//! padding is applied is to format your input, then pad this resulting string
+//! to obtain your output:
+//!
+//! ```
+//! println!("Hello {:^15}!", format!("{:?}", Some("hi"))); // => "Hello   Some("hi")   !"
+//! ```
 //!
 //! ## Sign/`#`/`0`
 //!