44
55use super :: * ;
66use cssparser:: ParserInput ;
7- use serde_json:: { json , Value } ;
7+ use serde_json:: { Value , json } ;
88
99fn almost_equals ( a : & Value , b : & Value ) -> bool {
1010 match ( a, b) {
1111 ( Value :: Number ( a) , Value :: Number ( b) ) => {
1212 let a = a. as_f64 ( ) . unwrap ( ) ;
1313 let b = b. as_f64 ( ) . unwrap ( ) ;
1414 ( a - b) . abs ( ) <= a. abs ( ) * 1e-6
15- }
15+ } ,
1616
1717 ( & Value :: Bool ( a) , & Value :: Bool ( b) ) => a == b,
1818 ( Value :: String ( a) , Value :: String ( b) ) => a == b,
1919 ( Value :: Array ( a) , Value :: Array ( b) ) => {
2020 a. len ( ) == b. len ( ) && a. iter ( ) . zip ( b. iter ( ) ) . all ( |( a, b) | almost_equals ( a, b) )
21- }
21+ } ,
2222 ( & Value :: Object ( _) , & Value :: Object ( _) ) => panic ! ( "Not implemented" ) ,
2323 ( & Value :: Null , & Value :: Null ) => true ,
2424 _ => false ,
@@ -52,7 +52,7 @@ fn run_raw_json_tests<F: Fn(Value, Value)>(json_data: &str, run: F) {
5252 ( & Some ( _) , expected) => {
5353 let input = input. take ( ) . unwrap ( ) ;
5454 run ( input, expected)
55- }
55+ } ,
5656 } ;
5757 }
5858}
@@ -63,7 +63,7 @@ fn run_json_tests<F: Fn(&mut Parser) -> Value>(json_data: &str, parse: F) {
6363 let mut parse_input = ParserInput :: new ( & input) ;
6464 let result = parse ( & mut Parser :: new ( & mut parse_input) ) ;
6565 assert_json_eq ( result, expected, & input) ;
66- }
66+ } ,
6767 _ => panic ! ( "Unexpected JSON" ) ,
6868 } ) ;
6969}
@@ -207,7 +207,7 @@ impl ToJson for Color {
207207 Color :: CurrentColor => "currentcolor" . to_json ( ) ,
208208 Color :: Rgba ( ref rgba) => {
209209 json ! ( [ rgba. red, rgba. green, rgba. blue, rgba. alpha] )
210- }
210+ } ,
211211 Color :: Hsl ( ref c) => json ! ( [ c. hue, c. saturation, c. lightness, c. alpha] ) ,
212212 Color :: Hwb ( ref c) => json ! ( [ c. hue, c. whiteness, c. blackness, c. alpha] ) ,
213213 Color :: Lab ( ref c) => json ! ( [ c. lightness, c. a, c. b, c. alpha] ) ,
@@ -216,7 +216,7 @@ impl ToJson for Color {
216216 Color :: Oklch ( ref c) => json ! ( [ c. lightness, c. chroma, c. hue, c. alpha] ) ,
217217 Color :: ColorFunction ( ref c) => {
218218 json ! ( [ c. color_space. to_css_string( ) , c. c1, c. c2, c. c3, c. alpha] )
219- }
219+ } ,
220220 }
221221 }
222222}
0 commit comments