Skip to content

Commit

Permalink
Omit a layer of unnecessary nesting from Debug impl
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 9, 2020
1 parent baae6d9 commit 351d847
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
12 changes: 10 additions & 2 deletions src/value/mod.rs
Expand Up @@ -177,8 +177,16 @@ impl Debug for Value {
Value::Bool(v) => formatter.debug_tuple("Bool").field(&v).finish(),
Value::Number(ref v) => Debug::fmt(v, formatter),
Value::String(ref v) => formatter.debug_tuple("String").field(v).finish(),
Value::Array(ref v) => formatter.debug_tuple("Array").field(v).finish(),
Value::Object(ref v) => formatter.debug_tuple("Object").field(v).finish(),
Value::Array(ref v) => {
formatter.write_str("Array(")?;
Debug::fmt(v, formatter)?;
formatter.write_str(")")
}
Value::Object(ref v) => {
formatter.write_str("Object(")?;
Debug::fmt(v, formatter)?;
formatter.write_str(")")
}
}
}
}
Expand Down
22 changes: 9 additions & 13 deletions tests/debug.rs
Expand Up @@ -50,20 +50,16 @@ fn error() {
assert_eq!(format!("{:?}", err), expected);
}

const INDENTED_EXPECTED: &str = r#"Object(
{
"array": Array(
[
Number(
0,
),
Number(
1,
),
],
const INDENTED_EXPECTED: &str = r#"Object({
"array": Array([
Number(
0,
),
},
)"#;
Number(
1,
),
]),
})"#;

#[test]
fn indented() {
Expand Down

0 comments on commit 351d847

Please sign in to comment.