Skip to content

Commit 3abfcef

Browse files
committed
prefix hex representation of binary values with "0x"
1 parent a064c34 commit 3abfcef

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/bson.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Display for Bson {
9090

9191
format!("Timestamp({}, {})", time, inc)
9292
}
93-
&Bson::Binary(t, ref vec) => format!("BinData({}, {})", u8::from(t), vec.to_hex()),
93+
&Bson::Binary(t, ref vec) => format!("BinData({}, 0x{})", u8::from(t), vec.to_hex()),
9494
&Bson::ObjectId(ref id) => {
9595
let mut vec = vec![];
9696

tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn test_format() {
4545
"date" => (Bson::UtcDatetime(date))
4646
};
4747

48-
let expected = format!("{{ float: 2.4, string: \"hello\", array: [\"testing\", 1], doc: {{ fish: \"in\", a: \"barrel\", !: 1 }}, bool: true, null: null, regexp: /s[ao]d/i, code: function(x) {{ return x._id; }}, i32: 12, i64: -55, timestamp: Timestamp(0, 229999444), binary: BinData(5, {}), _id: ObjectId(\"{}\"), date: Date(\"{}\") }}", "thingies".as_bytes().to_hex(), id_string, date);
48+
let expected = format!("{{ float: 2.4, string: \"hello\", array: [\"testing\", 1], doc: {{ fish: \"in\", a: \"barrel\", !: 1 }}, bool: true, null: null, regexp: /s[ao]d/i, code: function(x) {{ return x._id; }}, i32: 12, i64: -55, timestamp: Timestamp(0, 229999444), binary: BinData(5, 0x{}), _id: ObjectId(\"{}\"), date: Date(\"{}\") }}", "thingies".as_bytes().to_hex(), id_string, date);
4949

5050
assert_eq!(expected, format!("{}", doc));
5151
}

0 commit comments

Comments
 (0)