Skip to content

Bson doesn't uphold Eq's reflexivity guarantee #683

Description

@tyilo

According to the Eq documentation any type implementing the trait should ensure that all values are reflexive.

This is not the case for Bson even though it implements Eq:

fn main() {
    let v = bson::Bson::Double(f64::NAN);
    assert_eq!(v, v);
}
thread 'main' (2304097) panicked at src/main.rs:3:5:
assertion `left == right` failed
  left: Double(NaN)
 right: Double(NaN)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Either the Eq implementation should be removed or Bson::eq should compare the bits of f64's (or something similar).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions