Skip to content

Commit 1fff644

Browse files
committed
Revert "Merge branch 'master' of https://github.com/mongodb/bson-rust"
This reverts commit 84ba2d6, reversing changes made to 6208809.
1 parent 84ba2d6 commit 1fff644

File tree

6 files changed

+9
-92
lines changed

6 files changed

+9
-92
lines changed

src/bson.rs

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
//! BSON definition
2323
24-
use std::fmt::{self, Debug, Display, Formatter};
24+
use std::fmt::{self, Debug, Display};
2525

2626
use chrono::Datelike;
2727
use serde_json::{json, Value};
@@ -34,7 +34,7 @@ use crate::{
3434
};
3535

3636
/// Possible BSON value types.
37-
#[derive(Clone, PartialEq)]
37+
#[derive(Clone, Debug, PartialEq)]
3838
pub enum Bson {
3939
/// 64-bit binary floating point
4040
Double(f64),
@@ -146,40 +146,6 @@ impl Display for Bson {
146146
}
147147
}
148148

149-
impl Debug for Bson {
150-
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
151-
match *self {
152-
Bson::Double(f) => fmt.debug_tuple("Double").field(&f).finish(),
153-
Bson::String(ref s) => fmt.debug_tuple("String").field(s).finish(),
154-
Bson::Array(ref vec) => {
155-
write!(fmt, "Array(")?;
156-
Debug::fmt(vec, fmt)?;
157-
write!(fmt, ")")
158-
}
159-
Bson::Document(ref doc) => Debug::fmt(doc, fmt),
160-
Bson::Boolean(b) => fmt.debug_tuple("Boolean").field(&b).finish(),
161-
Bson::Null => write!(fmt, "Null"),
162-
Bson::RegularExpression(ref regex) => Debug::fmt(regex, fmt),
163-
Bson::JavaScriptCode(ref code) => {
164-
fmt.debug_tuple("JavaScriptCode").field(code).finish()
165-
}
166-
Bson::JavaScriptCodeWithScope(ref code) => Debug::fmt(code, fmt),
167-
Bson::Int32(i) => fmt.debug_tuple("Int32").field(&i).finish(),
168-
Bson::Int64(i) => fmt.debug_tuple("Int64").field(&i).finish(),
169-
Bson::Timestamp(ref t) => Debug::fmt(t, fmt),
170-
Bson::Binary(ref b) => Debug::fmt(b, fmt),
171-
Bson::ObjectId(ref id) => Debug::fmt(id, fmt),
172-
Bson::DateTime(ref date_time) => Debug::fmt(date_time, fmt),
173-
Bson::Symbol(ref sym) => fmt.debug_tuple("Symbol").field(sym).finish(),
174-
Bson::Decimal128(ref d) => Debug::fmt(d, fmt),
175-
Bson::Undefined => write!(fmt, "Undefined"),
176-
Bson::MinKey => write!(fmt, "MinKey"),
177-
Bson::MaxKey => write!(fmt, "MaxKey"),
178-
Bson::DbPointer(ref pointer) => Debug::fmt(pointer, fmt),
179-
}
180-
}
181-
}
182-
183149
impl From<f32> for Bson {
184150
fn from(a: f32) -> Bson {
185151
Bson::Double(a as f64)

src/datetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl crate::DateTime {
7070

7171
/// Returns a [`DateTime`] which corresponds to the current date and time.
7272
pub fn now() -> DateTime {
73-
Self::from_system_time(SystemTime::now())
73+
Self::from_chrono(Utc::now())
7474
}
7575

7676
#[cfg(not(feature = "chrono-0_4"))]

src/document.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ impl Display for Document {
9292
}
9393

9494
impl Debug for Document {
95-
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
96-
write!(fmt, "Document(")?;
97-
Debug::fmt(&self.inner, fmt)?;
98-
write!(fmt, ")")
95+
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
96+
write!(f, "Document({:?})", self.inner)
9997
}
10098
}
10199

src/oid.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl ObjectId {
163163
}
164164

165165
/// Returns the raw byte representation of an ObjectId.
166-
pub const fn bytes(&self) -> [u8; 12] {
166+
pub fn bytes(&self) -> [u8; 12] {
167167
self.id
168168
}
169169

@@ -223,7 +223,7 @@ impl fmt::Display for ObjectId {
223223

224224
impl fmt::Debug for ObjectId {
225225
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
226-
f.debug_tuple("ObjectId").field(&self.to_hex()).finish()
226+
f.write_str(&format!("ObjectId({})", self.to_hex()))
227227
}
228228
}
229229

@@ -301,14 +301,7 @@ mod test {
301301
fn test_debug() {
302302
let id = super::ObjectId::parse_str("53e37d08776f724e42000000").unwrap();
303303

304-
assert_eq!(
305-
format!("{:?}", id),
306-
"ObjectId(\"53e37d08776f724e42000000\")"
307-
);
308-
assert_eq!(
309-
format!("{:#?}", id),
310-
"ObjectId(\n \"53e37d08776f724e42000000\",\n)"
311-
);
304+
assert_eq!(format!("{:?}", id), "ObjectId(53e37d08776f724e42000000)")
312305
}
313306

314307
#[test]

src/ser/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub enum Error {
1414
/// A key could not be serialized to a BSON string.
1515
InvalidDocumentKey(Bson),
1616

17-
/// A general error that occurred during serialization.
17+
/// A general error that ocurred during serialization.
1818
/// See: https://docs.rs/serde/1.0.110/serde/ser/trait.Error.html#tymethod.custom
1919
#[non_exhaustive]
2020
SerializationError {

src/tests/modules/bson.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -306,43 +306,3 @@ fn system_time() {
306306
0
307307
);
308308
}
309-
310-
#[test]
311-
fn debug_print() {
312-
let oid = ObjectId::parse_str("000000000000000000000000").unwrap();
313-
314-
let doc = doc! {
315-
"oid": oid,
316-
"arr": Bson::Array(vec! [
317-
Bson::Null,
318-
Bson::Timestamp(Timestamp { time: 1, increment: 1 }),
319-
]),
320-
"doc": doc! { "a": 1, "b": "data"},
321-
};
322-
let normal_print = "Document({\"oid\": ObjectId(\"000000000000000000000000\"), \"arr\": \
323-
Array([Null, Timestamp { time: 1, increment: 1 }]), \"doc\": \
324-
Document({\"a\": Int32(1), \"b\": String(\"data\")})})";
325-
let pretty_print = "Document({
326-
\"oid\": ObjectId(
327-
\"000000000000000000000000\",
328-
),
329-
\"arr\": Array([
330-
Null,
331-
Timestamp {
332-
time: 1,
333-
increment: 1,
334-
},
335-
]),
336-
\"doc\": Document({
337-
\"a\": Int32(
338-
1,
339-
),
340-
\"b\": String(
341-
\"data\",
342-
),
343-
}),
344-
})";
345-
346-
assert_eq!(format!("{:?}", doc), normal_print);
347-
assert_eq!(format!("{:#?}", doc), pretty_print);
348-
}

0 commit comments

Comments
 (0)