Add trailing , for 1-tuples
This commit is contained in:
parent
0bcbd16931
commit
b0ab164b80
@ -175,6 +175,12 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
|
||||
fn is_pretty(&self) -> bool {
|
||||
self.fmt.flags() & (1 << (FlagV1::Alternate as usize)) != 0
|
||||
}
|
||||
|
||||
/// Returns the wrapped `Formatter`.
|
||||
#[unstable(feature = "debug_builder_formatter", reason = "recently added")]
|
||||
pub fn formatter(&mut self) -> &mut fmt::Formatter<'b> {
|
||||
&mut self.fmt
|
||||
}
|
||||
}
|
||||
|
||||
struct DebugInner<'a, 'b: 'a> {
|
||||
|
@ -1490,7 +1490,16 @@ macro_rules! tuple {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
let mut builder = f.debug_tuple("");
|
||||
let ($(ref $name,)*) = *self;
|
||||
$(builder.field($name);)*
|
||||
let mut n = 0;
|
||||
$(
|
||||
builder.field($name);
|
||||
n += 1;
|
||||
)*
|
||||
|
||||
if n == 1 {
|
||||
try!(write!(builder.formatter(), ","));
|
||||
}
|
||||
|
||||
builder.finish()
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ fn test_tuple_cmp() {
|
||||
#[test]
|
||||
fn test_show() {
|
||||
let s = format!("{:?}", (1,));
|
||||
assert_eq!(s, "(1)");
|
||||
assert_eq!(s, "(1,)");
|
||||
let s = format!("{:?}", (1, true));
|
||||
assert_eq!(s, "(1, true)");
|
||||
let s = format!("{:?}", (1, "hi", true));
|
||||
|
Loading…
Reference in New Issue
Block a user