Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/libcore/fmt/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
13 changes: 6 additions & 7 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1488,20 +1488,19 @@ macro_rules! tuple {
impl<$($name:Debug),*> Debug for ($($name,)*) {
#[allow(non_snake_case, unused_assignments)]
fn fmt(&self, f: &mut Formatter) -> Result {
try!(write!(f, "("));
let mut builder = f.debug_tuple("");
let ($(ref $name,)*) = *self;
let mut n = 0;
$(
if n > 0 {
try!(write!(f, ", "));
}
try!(write!(f, "{:?}", *$name));
builder.field($name);
n += 1;
)*

if n == 1 {
try!(write!(f, ","));
try!(write!(builder.formatter(), ","));
}
write!(f, ")")

builder.finish()
}
}
peel! { $($name,)* }
Expand Down