Skip to content

Commit

Permalink
fix: Don't use the type for constants; use std (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex P authored Jun 5, 2020
1 parent c9d103e commit 932cfcc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/bson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,9 @@ impl Bson {
}

["$numberDouble"] => match doc.get_str("$numberDouble") {
Ok("Infinity") => return Bson::Double(f64::INFINITY),
Ok("-Infinity") => return Bson::Double(f64::NEG_INFINITY),
Ok("NaN") => return Bson::Double(f64::NAN),
Ok("Infinity") => return Bson::Double(std::f64::INFINITY),
Ok("-Infinity") => return Bson::Double(std::f64::NEG_INFINITY),
Ok("NaN") => return Bson::Double(std::f64::NAN),
Ok(other) => {
if let Ok(d) = other.parse() {
return Bson::Double(d);
Expand Down Expand Up @@ -692,7 +692,10 @@ impl Bson {

if let Ok(t) = timestamp.get_i64("t") {
if let Ok(i) = timestamp.get_i64("i") {
if t >= 0 && i >= 0 && t <= (u32::MAX as i64) && i <= (u32::MAX as i64)
if t >= 0
&& i >= 0
&& t <= (std::u32::MAX as i64)
&& i <= (std::u32::MAX as i64)
{
return Bson::Timestamp(Timestamp {
time: t as u32,
Expand Down
2 changes: 1 addition & 1 deletion src/extjson/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl TryFrom<serde_json::Value> for Bson {
serde_json::Value::Number(x) => x
.as_i64()
.map(|i| {
if i >= i32::MIN as i64 && i <= i32::MAX as i64 {
if i >= std::i32::MIN as i64 && i <= std::i32::MAX as i64 {
Bson::Int32(i as i32)
} else {
Bson::Int64(i)
Expand Down
6 changes: 3 additions & 3 deletions src/extjson/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ pub(crate) struct Double {
impl Double {
pub(crate) fn parse(self) -> extjson::de::Result<f64> {
match self.value.as_str() {
"Infinity" => Ok(f64::INFINITY),
"-Infinity" => Ok(f64::NEG_INFINITY),
"NaN" => Ok(f64::NAN),
"Infinity" => Ok(std::f64::INFINITY),
"-Infinity" => Ok(std::f64::NEG_INFINITY),
"NaN" => Ok(std::f64::NAN),
other => {
let d: f64 = other.parse().map_err(|_| {
extjson::de::Error::invalid_value(
Expand Down

0 comments on commit 932cfcc

Please sign in to comment.