Skip to content

Commit 932cfcc

Browse files
author
Alex P
authored
fix: Don't use the type for constants; use std (#186)
1 parent c9d103e commit 932cfcc

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/bson.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,9 @@ impl Bson {
636636
}
637637

638638
["$numberDouble"] => match doc.get_str("$numberDouble") {
639-
Ok("Infinity") => return Bson::Double(f64::INFINITY),
640-
Ok("-Infinity") => return Bson::Double(f64::NEG_INFINITY),
641-
Ok("NaN") => return Bson::Double(f64::NAN),
639+
Ok("Infinity") => return Bson::Double(std::f64::INFINITY),
640+
Ok("-Infinity") => return Bson::Double(std::f64::NEG_INFINITY),
641+
Ok("NaN") => return Bson::Double(std::f64::NAN),
642642
Ok(other) => {
643643
if let Ok(d) = other.parse() {
644644
return Bson::Double(d);
@@ -692,7 +692,10 @@ impl Bson {
692692

693693
if let Ok(t) = timestamp.get_i64("t") {
694694
if let Ok(i) = timestamp.get_i64("i") {
695-
if t >= 0 && i >= 0 && t <= (u32::MAX as i64) && i <= (u32::MAX as i64)
695+
if t >= 0
696+
&& i >= 0
697+
&& t <= (std::u32::MAX as i64)
698+
&& i <= (std::u32::MAX as i64)
696699
{
697700
return Bson::Timestamp(Timestamp {
698701
time: t as u32,

src/extjson/de.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl TryFrom<serde_json::Value> for Bson {
185185
serde_json::Value::Number(x) => x
186186
.as_i64()
187187
.map(|i| {
188-
if i >= i32::MIN as i64 && i <= i32::MAX as i64 {
188+
if i >= std::i32::MIN as i64 && i <= std::i32::MAX as i64 {
189189
Bson::Int32(i as i32)
190190
} else {
191191
Bson::Int64(i)

src/extjson/models.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ pub(crate) struct Double {
5656
impl Double {
5757
pub(crate) fn parse(self) -> extjson::de::Result<f64> {
5858
match self.value.as_str() {
59-
"Infinity" => Ok(f64::INFINITY),
60-
"-Infinity" => Ok(f64::NEG_INFINITY),
61-
"NaN" => Ok(f64::NAN),
59+
"Infinity" => Ok(std::f64::INFINITY),
60+
"-Infinity" => Ok(std::f64::NEG_INFINITY),
61+
"NaN" => Ok(std::f64::NAN),
6262
other => {
6363
let d: f64 = other.parse().map_err(|_| {
6464
extjson::de::Error::invalid_value(

0 commit comments

Comments
 (0)