File tree Expand file tree Collapse file tree 6 files changed +1
-32
lines changed
Expand file tree Collapse file tree 6 files changed +1
-32
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ default-features = false
1616
1717[features ]
1818float_deserialize = [" serde" ]
19- lax_deserialize = [" float_deserialize" ]
2019default = [" std" ]
2120std = []
2221
Original file line number Diff line number Diff line change @@ -590,11 +590,8 @@ impl<'de> Deserialize<'de> for Int {
590590
591591 #[ cfg( feature = "float_deserialize" ) ]
592592 {
593- #[ cfg( not( feature = "lax_deserialize" ) ) ]
594593 const EXPECTING : & str =
595594 "a number between -2^53 + 1 and 2^53 - 1 without fractional component" ;
596- #[ cfg( feature = "lax_deserialize" ) ]
597- const EXPECTING : & str = "a number between -2^53 + 1 and 2^53 - 1" ;
598595
599596 let val = f64:: deserialize ( deserializer) ?;
600597
Original file line number Diff line number Diff line change @@ -57,12 +57,5 @@ pub use self::{
5757#[ cfg( feature = "float_deserialize" ) ]
5858#[ inline( always) ]
5959pub ( crate ) fn is_acceptable_float ( float : f64 ) -> bool {
60- #[ cfg( not( feature = "lax_deserialize" ) ) ]
61- {
62- if float. fract ( ) != 0.0 {
63- return false ;
64- }
65- }
66-
67- !float. is_nan ( )
60+ !float. is_nan ( ) && float. fract ( ) == 0.0
6861}
Original file line number Diff line number Diff line change @@ -585,10 +585,7 @@ impl<'de> Deserialize<'de> for UInt {
585585
586586 #[ cfg( feature = "float_deserialize" ) ]
587587 {
588- #[ cfg( not( feature = "lax_deserialize" ) ) ]
589588 const EXPECTING : & str = "a number between 0 and 2^53 - 1 without fractional component" ;
590- #[ cfg( feature = "lax_deserialize" ) ]
591- const EXPECTING : & str = "a number between 0 and 2^53 - 1" ;
592589
593590 let val = f64:: deserialize ( deserializer) ?;
594591
Original file line number Diff line number Diff line change @@ -41,7 +41,6 @@ fn dont_deserialize_integral_float() {
4141}
4242
4343#[ test]
44- #[ cfg_attr( feature = "lax_deserialize" , ignore) ]
4544fn dont_deserialize_fractional_float ( ) {
4645 assert ! ( deserialize_from( 0.5 ) . is_err( ) ) ;
4746 assert ! ( deserialize_from( 42.1337 ) . is_err( ) ) ;
@@ -67,14 +66,6 @@ fn deserialize_integral_float() {
6766 assert ! ( deserialize_from( f64 :: NEG_INFINITY ) . is_err( ) ) ;
6867}
6968
70- #[ test]
71- #[ cfg_attr( not( feature = "lax_deserialize" ) , ignore) ]
72- fn deserialize_fractional_float ( ) {
73- assert_eq ! ( deserialize_from( 0.5 ) . unwrap( ) , int!( 0 ) ) ;
74- assert_eq ! ( deserialize_from( 42.1337 ) . unwrap( ) , int!( 42 ) ) ;
75- assert_eq ! ( deserialize_from( -42.1337 ) . unwrap( ) , int!( -42 ) ) ;
76- }
77-
7869fn deserialize_from < ' de , Value : IntoDeserializer < ' de > > (
7970 value : Value ,
8071) -> Result < Int , serde:: de:: value:: Error > {
Original file line number Diff line number Diff line change @@ -35,7 +35,6 @@ fn dont_deserialize_integral_float() {
3535}
3636
3737#[ test]
38- #[ cfg_attr( feature = "lax_deserialize" , ignore) ]
3938fn dont_deserialize_fractional_float ( ) {
4039 assert ! ( deserialize_from( 0.5 ) . is_err( ) ) ;
4140 assert ! ( deserialize_from( 42.1337 ) . is_err( ) ) ;
@@ -58,13 +57,6 @@ fn deserialize_integral_float() {
5857 assert ! ( deserialize_from( f64 :: NEG_INFINITY ) . is_err( ) ) ;
5958}
6059
61- #[ test]
62- #[ cfg_attr( not( feature = "lax_deserialize" ) , ignore) ]
63- fn deserialize_fractional_float ( ) {
64- assert_eq ! ( deserialize_from( 0.5 ) . unwrap( ) , uint!( 0 ) ) ;
65- assert_eq ! ( deserialize_from( 42.1337 ) . unwrap( ) , uint!( 42 ) ) ;
66- }
67-
6860fn deserialize_from < ' de , Value : IntoDeserializer < ' de > > (
6961 value : Value ,
7062) -> Result < UInt , serde:: de:: value:: Error > {
You can’t perform that action at this time.
0 commit comments