Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

Commit 620479c

Browse files
authored
replace nalgebra with approx (#201)
1 parent 0534b75 commit 620479c

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ default-features = false
3636
version = "0.4.1"
3737

3838
[dev-dependencies]
39-
nalgebra = "0.10.1"
39+
approx = "0.1.1"
4040

4141
[dev-dependencies.serde_json]
4242
features = ["preserve_order"]

tests/json/eq.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use bson::Bson;
2-
use nalgebra::ApproxEq;
32

43
pub trait NumEq {
54
fn float_eq(&self, f: f64) -> bool;
@@ -10,16 +9,16 @@ pub trait NumEq {
109
impl NumEq for Bson {
1110
fn float_eq(&self, f: f64) -> bool {
1211
match *self {
13-
Bson::FloatingPoint(ref ff) => f.approx_eq(ff),
14-
Bson::I32(i) => f.approx_eq(&(i as f64)),
15-
Bson::I64(i) => f.approx_eq(&(i as f64)),
12+
Bson::FloatingPoint(ff) => ulps_eq!(ff, f),
13+
Bson::I32(i) => ulps_eq!(i as f64, f),
14+
Bson::I64(i) => ulps_eq!(i as f64, f),
1615
_ => false,
1716
}
1817
}
1918

2019
fn int_eq(&self, i: i64) -> bool {
2120
match *self {
22-
Bson::FloatingPoint(ref f) => f.approx_eq(&(i as f64)),
21+
Bson::FloatingPoint(f) => ulps_eq!(f, i as f64),
2322
Bson::I32(ii) => i == (ii as i64),
2423
Bson::I64(ii) => i == ii,
2524
_ => false,
@@ -72,8 +71,7 @@ pub fn bson_eq(b1: &Bson, b2: &Bson) -> bool {
7271
var_match!(*b2, Bson::UtcDatetime(other_date_time) =>
7372
date_time == other_date_time)
7473
}
75-
Bson::Symbol(ref s1) => {
76-
var_match!(*b2, Bson::Symbol(ref s2) => s1 == s2)
77-
}
74+
Bson::Symbol(ref s1) => var_match!(*b2, Bson::Symbol(ref s2) => s1 == s2),
7875
}
7976
}
77+

tests/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@
3838
wrong_pub_self_convention,
3939
))]
4040

41+
#[macro_use(ulps_eq)]
42+
extern crate approx;
4143
#[macro_use(bson, doc)]
4244
extern crate bson;
4345
extern crate mongodb;
44-
extern crate nalgebra;
4546
extern crate rand;
4647
extern crate serde_json;
4748

0 commit comments

Comments
 (0)