]> Repositorios git - scryer-prolog.git/commitdiff
check for num in comparisons, bump num-rug-adapter to 0.1.3
authorMark Thom <[email protected]>
Mon, 20 Apr 2020 16:35:30 +0000 (10:35 -0600)
committerMark Thom <[email protected]>
Mon, 20 Apr 2020 16:35:30 +0000 (10:35 -0600)
Cargo.lock
Cargo.toml
src/prolog/arithmetic.rs

index 67fa47a01b72158f65907ee237903c1260c30653..ede5aa3da9f18896b6c13fdd28ca5dedb0dcd665 100644 (file)
@@ -411,7 +411,7 @@ dependencies = [
 
 [[package]]
 name = "num-rug-adapter"
-version = "0.1.2"
+version = "0.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -491,11 +491,11 @@ dependencies = [
 
 [[package]]
 name = "prolog_parser"
-version = "0.8.52"
+version = "0.8.53"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "lexical 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "num-rug-adapter 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-rug-adapter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "rug 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "unicode_reader 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -636,9 +636,9 @@ dependencies = [
  "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
  "nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "num-rug-adapter 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-rug-adapter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "prolog_parser 0.8.52 (registry+https://github.com/rust-lang/crates.io-index)",
+ "prolog_parser 0.8.53 (registry+https://github.com/rust-lang/crates.io-index)",
  "ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rug 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustyline 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -861,7 +861,7 @@ dependencies = [
 "checksum num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9c3f34cdd24f334cb265d9bf8bfa8a241920d026916785747a92f0e55541a1a"
 "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"
 "checksum num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2885278d5fe2adc2f75ced642d52d879bffaceb5a2e0b1d4309ffdfb239b454"
-"checksum num-rug-adapter 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "486dba36bc7a5f525ef126495e8dd620c625de9f81dd9add2d17c5a547eb272b"
+"checksum num-rug-adapter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c8a5260184b793d3f17a020cd8633075a7c722ebc9c5a4d8c0a5ad784676d70b"
 "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
 "checksum num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "443c53b3c3531dfcbfa499d8893944db78474ad7a1d87fa2d94d1a2231693ac6"
 "checksum ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7eb5259643245d3f292c7a146b2df53bba24d7eab159410e648eb73dc164669d"
@@ -870,7 +870,7 @@ dependencies = [
 "checksum proc-macro-hack 0.5.14 (registry+https://github.com/rust-lang/crates.io-index)" = "fcfdefadc3d57ca21cf17990a28ef4c0f7c61383a28cb7604cf4a18e6ede1420"
 "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
 "checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435"
-"checksum prolog_parser 0.8.52 (registry+https://github.com/rust-lang/crates.io-index)" = "6d9baffc92f102756f07ef5a367409d4d78ddb5c32bc3bd6ee4584a27f79408d"
+"checksum prolog_parser 0.8.53 (registry+https://github.com/rust-lang/crates.io-index)" = "772ac5f493b6c0d1a4fb486da6b05cba8d2486f4d7f9872ae363d5fb097728c7"
 "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
 "checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
 "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
index 5ac133cf4a72f72b220b7e0d78db1667d12d110e..462ca3565e59dbf04cea0ef41ae43d98e6d52233 100644 (file)
@@ -25,9 +25,9 @@ indexmap = "1.0.2"
 lazy_static = "1.4.0"
 libc = "0.2.62"
 nix = "0.15.0"
-num-rug-adapter = { optional = true, version = "0.1.2" }
+num-rug-adapter = { optional = true, version = "0.1.3" }
 ordered-float = "0.5.0"
-prolog_parser = { version = "0.8.52", default-features = false }
+prolog_parser = { version = "0.8.53", default-features = false }
 ref_thread_local = "0.0.0"
 rug = { version = "1.4.0", optional = true }
 rustyline = "6.0.0"
index 5be0001bcc127739698990d437ee7760239a5b04..6946f5f415430ec4c5e75f44d5d69d57d1c49a98 100644 (file)
@@ -637,8 +637,26 @@ impl PartialEq for Number {
             (&Number::Integer(ref n1), &Number::Integer(ref n2)) => n1.eq(n2),
             (&Number::Integer(ref n1), Number::Float(n2)) => OrderedFloat(n1.to_f64()).eq(&n2),
             (&Number::Float(n1), &Number::Integer(ref n2)) => n1.eq(&OrderedFloat(n2.to_f64())),
-            (&Number::Integer(ref n1), &Number::Rational(ref n2)) => &**n1 == &**n2,
-            (&Number::Rational(ref n1), &Number::Integer(ref n2)) => &**n1 == &**n2,
+            (&Number::Integer(ref n1), &Number::Rational(ref n2)) => {
+                #[cfg(feature = "num")]
+                {
+                    &Rational::from(&**n1) == &**n2
+                }
+                #[cfg(not(feature = "num"))]
+                {
+                    &**n1 == &**n2
+                }
+            }
+            (&Number::Rational(ref n1), &Number::Integer(ref n2)) => {
+                #[cfg(feature = "num")]
+                {
+                    &**n1 == &Rational::from(&**n2)
+                }
+                #[cfg(not(feature = "num"))]
+                {
+                    &**n1 == &**n2
+                }
+            }
             (&Number::Rational(ref n1), &Number::Float(n2)) => OrderedFloat(n1.to_f64()).eq(&n2),
             (&Number::Float(n1), &Number::Rational(ref n2)) => n1.eq(&OrderedFloat(n2.to_f64())),
             (&Number::Float(f1), &Number::Float(f2)) => f1.eq(&f2),
@@ -668,10 +686,26 @@ impl Ord for Number {
             (&Number::Integer(ref n1), &Number::Integer(ref n2)) => n1.cmp(n2),
             (&Number::Integer(ref n1), Number::Float(n2)) => OrderedFloat(n1.to_f64()).cmp(&n2),
             (&Number::Float(n1), &Number::Integer(ref n2)) => n1.cmp(&OrderedFloat(n2.to_f64())),
-            (&Number::Integer(ref n1), &Number::Rational(ref n2)) =>
-                (&**n1).partial_cmp(&**n2).unwrap_or(Ordering::Less),
-            (&Number::Rational(ref n1), &Number::Integer(ref n2)) =>
-                (&**n1).partial_cmp(&**n2).unwrap_or(Ordering::Less),
+            (&Number::Integer(ref n1), &Number::Rational(ref n2)) => {
+                #[cfg(feature = "num")]
+                {
+                    Rational::from(&**n1).cmp(n2)
+                }
+                #[cfg(not(feature = "num"))]
+                {
+                    (&**n1).partial_cmp(&**n2).unwrap_or(Ordering::Less)
+                }
+            }
+            (&Number::Rational(ref n1), &Number::Integer(ref n2)) => {
+                #[cfg(feature = "num")]
+                {
+                    (&**n1).cmp(&Rational::from(&**n2))
+                }
+                #[cfg(not(feature = "num"))]
+                {
+                    (&**n1).partial_cmp(&**n2).unwrap_or(Ordering::Less)
+                }
+            }
             (&Number::Rational(ref n1), &Number::Float(n2)) => OrderedFloat(n1.to_f64()).cmp(&n2),
             (&Number::Float(n1), &Number::Rational(ref n2)) => n1.cmp(&OrderedFloat(n2.to_f64())),
             (&Number::Float(f1), &Number::Float(f2)) => f1.cmp(&f2),