diff --git a/Cargo.toml b/Cargo.toml index 6206740..aec8de6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ license = "MIT" edition = "2021" [dependencies] -num = "0.4" byteorder = "1" libflate = "2" +num-bigint = "0.4" +num-traits = "0.2.19" diff --git a/src/codec.rs b/src/codec.rs index 826c03b..77dfa99 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -4,7 +4,7 @@ use byteorder::BigEndian; use byteorder::ReadBytesExt; use byteorder::WriteBytesExt; use libflate::zlib; -use num::bigint::BigInt; +use num_bigint::BigInt; use std::convert::From; use std::io; use std::io::Write; @@ -767,7 +767,7 @@ impl Encoder { } mod aux { - use num::bigint::Sign; + use num_bigint::Sign; use std::io; use std::ops::Range; use std::str; diff --git a/src/convert.rs b/src/convert.rs index e1b15e3..cd94d69 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -104,7 +104,7 @@ impl AsOption for bool { } } -impl num::traits::ToPrimitive for FixInteger { +impl num_traits::ToPrimitive for FixInteger { fn to_i64(&self) -> Option { Some(i64::from(self.value)) } @@ -115,7 +115,7 @@ impl num::traits::ToPrimitive for FixInteger { Some(f64::from(self.value)) } } -impl num::traits::ToPrimitive for BigInteger { +impl num_traits::ToPrimitive for BigInteger { fn to_i64(&self) -> Option { self.value.to_i64() } @@ -126,7 +126,7 @@ impl num::traits::ToPrimitive for BigInteger { self.value.to_f64() } } -impl num::traits::ToPrimitive for Float { +impl num_traits::ToPrimitive for Float { fn to_i64(&self) -> Option { None } @@ -137,7 +137,7 @@ impl num::traits::ToPrimitive for Float { Some(self.value) } } -impl num::traits::ToPrimitive for Term { +impl num_traits::ToPrimitive for Term { fn to_i64(&self) -> Option { match *self { Term::FixInteger(ref x) => x.to_i64(), @@ -162,18 +162,18 @@ impl num::traits::ToPrimitive for Term { } } -impl num::bigint::ToBigInt for FixInteger { - fn to_bigint(&self) -> Option { +impl num_bigint::ToBigInt for FixInteger { + fn to_bigint(&self) -> Option { Some(BigInteger::from(self).value) } } -impl num::bigint::ToBigInt for BigInteger { - fn to_bigint(&self) -> Option { +impl num_bigint::ToBigInt for BigInteger { + fn to_bigint(&self) -> Option { Some(self.value.clone()) } } -impl num::bigint::ToBigInt for Term { - fn to_bigint(&self) -> Option { +impl num_bigint::ToBigInt for Term { + fn to_bigint(&self) -> Option { match *self { Term::FixInteger(ref x) => x.to_bigint(), Term::BigInteger(ref x) => x.to_bigint(), @@ -182,18 +182,18 @@ impl num::bigint::ToBigInt for Term { } } -impl num::bigint::ToBigUint for FixInteger { - fn to_biguint(&self) -> Option { +impl num_bigint::ToBigUint for FixInteger { + fn to_biguint(&self) -> Option { BigInteger::from(self).value.to_biguint() } } -impl num::bigint::ToBigUint for BigInteger { - fn to_biguint(&self) -> Option { +impl num_bigint::ToBigUint for BigInteger { + fn to_biguint(&self) -> Option { self.value.to_biguint() } } -impl num::bigint::ToBigUint for Term { - fn to_biguint(&self) -> Option { +impl num_bigint::ToBigUint for Term { + fn to_biguint(&self) -> Option { match *self { Term::FixInteger(ref x) => x.to_biguint(), Term::BigInteger(ref x) => x.to_biguint(), diff --git a/src/lib.rs b/src/lib.rs index 3e0b45e..0285856 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,7 @@ //! //! - [Erlang External Term Format](http://erlang.org/doc/apps/erts/erl_ext_dist.html) //! -use num::bigint::BigInt; +use num_bigint::BigInt; use std::collections::HashMap; use std::fmt; use std::hash::Hash; @@ -557,7 +557,7 @@ impl fmt::Display for InternalFun { uniq, .. } => { - use num::bigint::Sign; + use num_bigint::Sign; let uniq = BigInt::from_bytes_be(Sign::Plus, &uniq); write!(f, "#Fun<{}.{}.{}>", module, index, uniq) } diff --git a/src/pattern.rs b/src/pattern.rs index 5663237..38b814f 100644 --- a/src/pattern.rs +++ b/src/pattern.rs @@ -3,9 +3,9 @@ use super::*; use crate::convert::AsOption; use crate::convert::TryAsRef; -use num::bigint::ToBigInt; -use num::bigint::ToBigUint; -use num::traits::ToPrimitive; +use num_bigint::ToBigInt; +use num_bigint::ToBigUint; +use num_traits::ToPrimitive; use std::fmt::Debug; pub type Result<'a, T> = std::result::Result>; @@ -838,7 +838,7 @@ impl<'a> Pattern<'a> for I64 { #[derive(Debug, Clone)] pub struct Int; impl<'a> Pattern<'a> for Int { - type Output = num::BigInt; + type Output = num_bigint::BigInt; fn try_match(&self, input: &'a Term) -> Result<'a, Self::Output> { input.to_bigint().ok_or_else(|| self.unmatched(input)) } @@ -847,7 +847,7 @@ impl<'a> Pattern<'a> for Int { #[derive(Debug, Clone)] pub struct Uint; impl<'a> Pattern<'a> for Uint { - type Output = num::BigUint; + type Output = num_bigint::BigUint; fn try_match(&self, input: &'a Term) -> Result<'a, Self::Output> { input.to_biguint().ok_or_else(|| self.unmatched(input)) } diff --git a/tests/lib.rs b/tests/lib.rs index 883fd17..a4240bd 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,6 +1,3 @@ -extern crate eetf; -extern crate num; - use eetf::*; use std::io::Cursor;