From 2bc4a5e92aef51bd34a5b1a506c5edcee893d6ac Mon Sep 17 00:00:00 2001 From: wickerwaka Date: Sat, 30 Aug 2014 11:27:02 -0700 Subject: Center alignment for fmt Use '^' to specify center alignment in format strings. fmt!( "[{:^5s}]", "Hi" ) -> "[ Hi ]" fmt!( "[{:^5s}]", "H" ) -> "[ H ]" fmt!( "[{:^5d}]", 1i ) -> "[ 1 ]" fmt!( "[{:^5d}]", -1i ) -> "[ -1 ]" fmt!( "[{:^6d}]", 1i ) -> "[ 1 ]" fmt!( "[{:^6d}]", -1i ) -> "[ -1 ]" If the padding is odd then the padding on the right will be one character longer than the padding on the left. Tuples squashed --- src/libsyntax/ext/format.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 0994abaadc7..aa2c51c0225 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -430,6 +430,9 @@ impl<'a, 'b> Context<'a, 'b> { parse::AlignRight => { self.ecx.path_global(sp, self.rtpath("AlignRight")) } + parse::AlignCenter => { + self.ecx.path_global(sp, self.rtpath("AlignCenter")) + } parse::AlignUnknown => { self.ecx.path_global(sp, self.rtpath("AlignUnknown")) } -- cgit 1.4.1-3-g733a5