Skip to content

Commit

Permalink
Auto merge of serde-rs#223 - SuperFluffy:fix_import_serde, r=cuviper
Browse files Browse the repository at this point in the history
Fix import serde and rational deserialization

Similar to serde-rs#196 for num/complex, “use serde;” needed to be removed in num/rational.

Also, deserialization of `num/rational` needed to be fixed by adding type annotations.

This is in response to rust-num/num#222 (comment) of issue rust-num/num#222.

Also added a travis line, in response to rust-num/num#222 (comment). Hope it works.
  • Loading branch information
homu committed Aug 17, 2016
2 parents ccdf307 + eb486e8 commit b0fbced
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .travis/test_nightly.sh
Expand Up @@ -5,3 +5,6 @@ set -ex
cargo bench --verbose

cargo test --verbose --manifest-path=macros/Cargo.toml

# Build test for the serde feature
cargo build --verbose --features "serde"
5 changes: 1 addition & 4 deletions rational/src/lib.rs
Expand Up @@ -28,9 +28,6 @@ use std::hash;
use std::ops::{Add, Div, Mul, Neg, Rem, Sub};
use std::str::FromStr;

#[cfg(feature = "serde")]
use serde;

#[cfg(feature = "num-bigint")]
use bigint::{BigInt, BigUint, Sign};

Expand Down Expand Up @@ -604,7 +601,7 @@ impl<T> serde::Deserialize for Ratio<T>
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: serde::Deserializer
{
let (numer, denom) = try!(serde::Deserialize::deserialize(deserializer));
let (numer, denom): (T,T) = try!(serde::Deserialize::deserialize(deserializer));
if denom.is_zero() {
Err(serde::de::Error::invalid_value("denominator is zero"))
} else {
Expand Down

0 comments on commit b0fbced

Please sign in to comment.