@@ -461,7 +461,7 @@ impl<'a> Encoder<'a> {
461461 /// Creates a new JSON encoder whose output will be written to the writer
462462 /// specified.
463463 pub fn new ( writer : & ' a mut dyn fmt:: Write ) -> Encoder < ' a > {
464- Encoder { writer : writer , is_emitting_map_key : false , }
464+ Encoder { writer, is_emitting_map_key : false , }
465465 }
466466}
467467
@@ -513,7 +513,7 @@ impl<'a> crate::Encoder for Encoder<'a> {
513513 emit_enquoted_if_mapkey ! ( self , fmt_number_or_null( v) )
514514 }
515515 fn emit_f32 ( & mut self , v : f32 ) -> EncodeResult {
516- self . emit_f64 ( v as f64 )
516+ self . emit_f64 ( f64:: from ( v ) )
517517 }
518518
519519 fn emit_char ( & mut self , v : char ) -> EncodeResult {
@@ -763,7 +763,7 @@ impl<'a> crate::Encoder for PrettyEncoder<'a> {
763763 emit_enquoted_if_mapkey ! ( self , fmt_number_or_null( v) )
764764 }
765765 fn emit_f32 ( & mut self , v : f32 ) -> EncodeResult {
766- self . emit_f64 ( v as f64 )
766+ self . emit_f64 ( f64:: from ( v ) )
767767 }
768768
769769 fn emit_char ( & mut self , v : char ) -> EncodeResult {
@@ -1698,12 +1698,12 @@ impl<T: Iterator<Item=char>> Parser<T> {
16981698 if n2 < 0xDC00 || n2 > 0xDFFF {
16991699 return self . error ( LoneLeadingSurrogateInHexEscape )
17001700 }
1701- let c = ( ( ( n1 - 0xD800 ) as u32 ) << 10 |
1702- ( n2 - 0xDC00 ) as u32 ) + 0x1_0000 ;
1701+ let c = ( u32 :: from ( n1 - 0xD800 ) << 10 |
1702+ u32 :: from ( n2 - 0xDC00 ) ) + 0x1_0000 ;
17031703 res. push ( char:: from_u32 ( c) . unwrap ( ) ) ;
17041704 }
17051705
1706- n => match char:: from_u32 ( n as u32 ) {
1706+ n => match char:: from_u32 ( u32:: from ( n ) ) {
17071707 Some ( c) => res. push ( c) ,
17081708 None => return self . error ( InvalidUnicodeCodePoint ) ,
17091709 } ,
@@ -2405,7 +2405,7 @@ impl ToJson for Json {
24052405}
24062406
24072407impl ToJson for f32 {
2408- fn to_json ( & self ) -> Json { ( * self as f64 ) . to_json ( ) }
2408+ fn to_json ( & self ) -> Json { f64 :: from ( * self ) . to_json ( ) }
24092409}
24102410
24112411impl ToJson for f64 {
0 commit comments