@@ -3,7 +3,9 @@ use super::{Bytes, Versionstamp};
3
3
use std:: { borrow:: Cow , cmp} ;
4
4
5
5
#[ cfg( feature = "num-bigint" ) ]
6
- use std:: convert:: TryInto ;
6
+ use num_bigint:: Sign ;
7
+ #[ cfg( feature = "num-bigint" ) ]
8
+ use std:: convert:: TryFrom ;
7
9
8
10
#[ derive( Clone , Debug ) ]
9
11
pub enum Element < ' a > {
@@ -53,6 +55,16 @@ impl<'a, 'b> Ord for CmpElement<'a, 'b> {
53
55
( Element :: Int ( a) , Element :: Int ( b) ) => a. cmp ( b) ,
54
56
#[ cfg( feature = "num-bigint" ) ]
55
57
( Element :: BigInt ( a) , Element :: BigInt ( b) ) => a. cmp ( b) ,
58
+ #[ cfg( feature = "num-bigint" ) ]
59
+ ( Element :: BigInt ( a) , Element :: Int ( b) ) => match i64:: try_from ( a) {
60
+ Ok ( a) => a. cmp ( b) ,
61
+ Err ( _) => a. sign ( ) . cmp ( & Sign :: NoSign ) ,
62
+ } ,
63
+ #[ cfg( feature = "num-bigint" ) ]
64
+ ( Element :: Int ( a) , Element :: BigInt ( b) ) => match i64:: try_from ( b) {
65
+ Ok ( b) => a. cmp ( & b) ,
66
+ Err ( _) => Sign :: NoSign . cmp ( & b. sign ( ) ) ,
67
+ } ,
56
68
( Element :: Float ( a) , Element :: Float ( b) ) => {
57
69
f32_to_u32_be_bytes ( * a) . cmp ( & f32_to_u32_be_bytes ( * b) )
58
70
}
@@ -94,7 +106,7 @@ impl<'a> Element<'a> {
94
106
Element :: Tuple ( _) => super :: NESTED ,
95
107
Element :: Int ( _) => super :: INTZERO ,
96
108
#[ cfg( feature = "num-bigint" ) ]
97
- Element :: BigInt ( _) => super :: POSINTEND ,
109
+ Element :: BigInt ( _) => super :: INTZERO ,
98
110
Element :: Float ( _) => super :: FLOAT ,
99
111
Element :: Double ( _) => super :: DOUBLE ,
100
112
Element :: Bool ( v) => {
@@ -167,7 +179,7 @@ impl<'a> Element<'a> {
167
179
match self {
168
180
Element :: Int ( v) => Some ( * v) ,
169
181
#[ cfg( feature = "num-bigint" ) ]
170
- Element :: BigInt ( v) => v . try_into ( ) . ok ( ) ,
182
+ Element :: BigInt ( v) => i64 :: try_from ( v ) . ok ( ) ,
171
183
_ => None ,
172
184
}
173
185
}
0 commit comments