@@ -84,8 +84,7 @@ pub struct Real {
8484#[ derive( Clone , Debug , Eq , Hash , PartialEq , Serialize , Deserialize ) ]
8585pub enum Literal {
8686 Null ,
87- Integer ( i64 ) ,
88- UnsignedInteger ( u64 ) ,
87+ Integer ( i128 ) ,
8988 FixedPoint ( Real ) ,
9089 String ( String ) ,
9190 Blob ( Vec < u8 > ) ,
@@ -95,15 +94,21 @@ pub enum Literal {
9594 Placeholder ,
9695}
9796
97+ impl From < i128 > for Literal {
98+ fn from ( i : i128 ) -> Self {
99+ Literal :: Integer ( i)
100+ }
101+ }
102+
98103impl From < i64 > for Literal {
99104 fn from ( i : i64 ) -> Self {
100- Literal :: Integer ( i)
105+ Literal :: Integer ( i. into ( ) )
101106 }
102107}
103108
104109impl From < u64 > for Literal {
105110 fn from ( i : u64 ) -> Self {
106- Literal :: UnsignedInteger ( i )
111+ Literal :: Integer ( i . into ( ) )
107112 }
108113}
109114
@@ -115,7 +120,7 @@ impl From<i32> for Literal {
115120
116121impl From < u32 > for Literal {
117122 fn from ( i : u32 ) -> Self {
118- Literal :: UnsignedInteger ( i. into ( ) )
123+ Literal :: Integer ( i. into ( ) )
119124 }
120125}
121126
@@ -136,7 +141,6 @@ impl ToString for Literal {
136141 match * self {
137142 Literal :: Null => "NULL" . to_string ( ) ,
138143 Literal :: Integer ( ref i) => format ! ( "{}" , i) ,
139- Literal :: UnsignedInteger ( ref i) => format ! ( "{}" , i) ,
140144 Literal :: FixedPoint ( ref f) => format ! ( "{}.{}" , f. integral, f. fractional) ,
141145 Literal :: String ( ref s) => format ! ( "'{}'" , s. replace( '\'' , "''" ) ) ,
142146 Literal :: Blob ( ref bv) => format ! (
@@ -884,13 +888,7 @@ named!(pub integer_literal<CompleteByteSlice, Literal>,
884888 if sign. is_some( ) {
885889 intval *= -1 ;
886890 }
887- if intval > std:: i64 :: MAX as i128 {
888- Literal :: UnsignedInteger ( intval as u64 )
889- } else if intval < std:: i64 :: MIN as i128 {
890- panic!( "{:?} can't fit in a Literal::Integer" , intval)
891- } else {
892- Literal :: Integer ( intval as i64 )
893- }
891+ Literal :: Integer ( intval)
894892 } )
895893 )
896894) ;
0 commit comments