11use std:: { error:: Error as StdError , fmt, iter, num, str} ;
22
3- use serde :: {
3+ use serde_core :: {
44 de:: value:: BorrowedBytesDeserializer ,
55 de:: {
66 Deserialize , DeserializeSeed , Deserializer , EnumAccess ,
77 Error as SerdeError , IntoDeserializer , MapAccess , SeqAccess ,
88 Unexpected , VariantAccess , Visitor ,
99 } ,
10- serde_if_integer128,
1110} ;
1211
1312use crate :: {
@@ -206,22 +205,18 @@ impl<'r> DeRecord<'r> for DeStringRecord<'r> {
206205 ) -> Result < V :: Value , DeserializeError > {
207206 let x = self . next_field ( ) ?;
208207 if x == "true" {
209- return visitor. visit_bool ( true ) ;
208+ visitor. visit_bool ( true )
210209 } else if x == "false" {
211- return visitor. visit_bool ( false ) ;
210+ visitor. visit_bool ( false )
212211 } else if let Some ( n) = try_positive_integer64 ( x) {
213- return visitor. visit_u64 ( n) ;
212+ visitor. visit_u64 ( n)
214213 } else if let Some ( n) = try_negative_integer64 ( x) {
215- return visitor. visit_i64 ( n) ;
216- }
217- serde_if_integer128 ! {
218- if let Some ( n) = try_positive_integer128( x) {
219- return visitor. visit_u128( n) ;
220- } else if let Some ( n) = try_negative_integer128( x) {
221- return visitor. visit_i128( n) ;
222- }
223- }
224- if let Some ( n) = try_float ( x) {
214+ visitor. visit_i64 ( n)
215+ } else if let Some ( n) = try_positive_integer128 ( x) {
216+ visitor. visit_u128 ( n)
217+ } else if let Some ( n) = try_negative_integer128 ( x) {
218+ visitor. visit_i128 ( n)
219+ } else if let Some ( n) = try_float ( x) {
225220 visitor. visit_f64 ( n)
226221 } else {
227222 visitor. visit_str ( x)
@@ -297,22 +292,18 @@ impl<'r> DeRecord<'r> for DeByteRecord<'r> {
297292 ) -> Result < V :: Value , DeserializeError > {
298293 let x = self . next_field_bytes ( ) ?;
299294 if x == b"true" {
300- return visitor. visit_bool ( true ) ;
295+ visitor. visit_bool ( true )
301296 } else if x == b"false" {
302- return visitor. visit_bool ( false ) ;
297+ visitor. visit_bool ( false )
303298 } else if let Some ( n) = try_positive_integer64_bytes ( x) {
304- return visitor. visit_u64 ( n) ;
299+ visitor. visit_u64 ( n)
305300 } else if let Some ( n) = try_negative_integer64_bytes ( x) {
306- return visitor. visit_i64 ( n) ;
307- }
308- serde_if_integer128 ! {
309- if let Some ( n) = try_positive_integer128_bytes( x) {
310- return visitor. visit_u128( n) ;
311- } else if let Some ( n) = try_negative_integer128_bytes( x) {
312- return visitor. visit_i128( n) ;
313- }
314- }
315- if let Some ( n) = try_float_bytes ( x) {
301+ visitor. visit_i64 ( n)
302+ } else if let Some ( n) = try_positive_integer128_bytes ( x) {
303+ visitor. visit_u128 ( n)
304+ } else if let Some ( n) = try_negative_integer128_bytes ( x) {
305+ visitor. visit_i128 ( n)
306+ } else if let Some ( n) = try_float_bytes ( x) {
316307 visitor. visit_f64 ( n)
317308 } else if let Ok ( s) = str:: from_utf8 ( x) {
318309 visitor. visit_str ( s)
@@ -366,16 +357,12 @@ impl<'a, 'de: 'a, T: DeRecord<'de>> Deserializer<'de>
366357 deserialize_int ! ( deserialize_u16, visit_u16, u16 ) ;
367358 deserialize_int ! ( deserialize_u32, visit_u32, u32 ) ;
368359 deserialize_int ! ( deserialize_u64, visit_u64, u64 ) ;
369- serde_if_integer128 ! {
370- deserialize_int!( deserialize_u128, visit_u128, u128 ) ;
371- }
360+ deserialize_int ! ( deserialize_u128, visit_u128, u128 ) ;
372361 deserialize_int ! ( deserialize_i8, visit_i8, i8 ) ;
373362 deserialize_int ! ( deserialize_i16, visit_i16, i16 ) ;
374363 deserialize_int ! ( deserialize_i32, visit_i32, i32 ) ;
375364 deserialize_int ! ( deserialize_i64, visit_i64, i64 ) ;
376- serde_if_integer128 ! {
377- deserialize_int!( deserialize_i128, visit_i128, i128 ) ;
378- }
365+ deserialize_int ! ( deserialize_i128, visit_i128, i128 ) ;
379366
380367 fn deserialize_f32 < V : Visitor < ' de > > (
381368 self ,
@@ -747,14 +734,12 @@ impl DeserializeErrorKind {
747734 }
748735}
749736
750- serde_if_integer128 ! {
751- fn try_positive_integer128( s: & str ) -> Option <u128 > {
752- s. parse( ) . ok( )
753- }
737+ fn try_positive_integer128 ( s : & str ) -> Option < u128 > {
738+ s. parse ( ) . ok ( )
739+ }
754740
755- fn try_negative_integer128( s: & str ) -> Option <i128 > {
756- s. parse( ) . ok( )
757- }
741+ fn try_negative_integer128 ( s : & str ) -> Option < i128 > {
742+ s. parse ( ) . ok ( )
758743}
759744
760745fn try_positive_integer64 ( s : & str ) -> Option < u64 > {
@@ -777,14 +762,12 @@ fn try_negative_integer64_bytes(s: &[u8]) -> Option<i64> {
777762 str:: from_utf8 ( s) . ok ( ) . and_then ( |s| s. parse ( ) . ok ( ) )
778763}
779764
780- serde_if_integer128 ! {
781- fn try_positive_integer128_bytes( s: & [ u8 ] ) -> Option <u128 > {
782- str :: from_utf8( s) . ok( ) . and_then( |s| s. parse( ) . ok( ) )
783- }
765+ fn try_positive_integer128_bytes ( s : & [ u8 ] ) -> Option < u128 > {
766+ str:: from_utf8 ( s) . ok ( ) . and_then ( |s| s. parse ( ) . ok ( ) )
767+ }
784768
785- fn try_negative_integer128_bytes( s: & [ u8 ] ) -> Option <i128 > {
786- str :: from_utf8( s) . ok( ) . and_then( |s| s. parse( ) . ok( ) )
787- }
769+ fn try_negative_integer128_bytes ( s : & [ u8 ] ) -> Option < i128 > {
770+ str:: from_utf8 ( s) . ok ( ) . and_then ( |s| s. parse ( ) . ok ( ) )
788771}
789772
790773fn try_float_bytes ( s : & [ u8 ] ) -> Option < f64 > {
@@ -797,7 +780,7 @@ mod tests {
797780
798781 use {
799782 bstr:: BString ,
800- serde:: { de:: DeserializeOwned , serde_if_integer128 , Deserialize } ,
783+ serde:: { de:: DeserializeOwned , Deserialize } ,
801784 } ;
802785
803786 use crate :: {
@@ -946,12 +929,10 @@ mod tests {
946929 assert_eq ! ( got, 42 ) ;
947930 }
948931
949- serde_if_integer128 ! {
950- #[ test]
951- fn one_field_128( ) {
952- let got: i128 = de( & [ "2010223372036854775808" ] ) . unwrap( ) ;
953- assert_eq!( got, 2010223372036854775808 ) ;
954- }
932+ #[ test]
933+ fn one_field_128 ( ) {
934+ let got: i128 = de ( & [ "2010223372036854775808" ] ) . unwrap ( ) ;
935+ assert_eq ! ( got, 2010223372036854775808 ) ;
955936 }
956937
957938 #[ test]
0 commit comments