From dc7bed5b2d46f87993bde81e9e9ef96ee545f520 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 12 Jul 2020 14:42:13 +0800 Subject: [PATCH] feat(single-file-tests): add format sample --- single_file_tests/format.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/single_file_tests/format.rs b/single_file_tests/format.rs index b21c3e9..a3b76c9 100644 --- a/single_file_tests/format.rs +++ b/single_file_tests/format.rs @@ -1,4 +1,6 @@ +// format: +// { [argument] ':' [[fill] align] [sign] ['#'] [width [$]] ['.' precision [$]] [type] } fn main() { let a = 1111111; @@ -8,4 +10,8 @@ fn main() { println!("octet: {:o}", a); println!("0x{:x}", a); println!("0x{:X}", a); + + println!("{0} {1}", "AA", "BB"); + println!("{a} {b}", a = "AA", b = "BB"); + println!("[{a:^6}] [{b:<6}] [{b:>6}] [{c:<10.3}]", a = "AA", b = "BB", c = 111.1); } \ No newline at end of file