Skip to content

Commit a32ada1

Browse files
committed
Run cargo fmt
Signed-off-by: Oriol Brufau <[email protected]>
1 parent 60d05a5 commit a32ada1

File tree

12 files changed

+104
-100
lines changed

12 files changed

+104
-100
lines changed

color/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
mod tests;
1313

1414
use cssparser::color::{
15-
clamp_floor_256_f32, clamp_unit_f32, parse_hash_color, serialize_color_alpha,
16-
PredefinedColorSpace, OPAQUE,
15+
OPAQUE, PredefinedColorSpace, clamp_floor_256_f32, clamp_unit_f32, parse_hash_color,
16+
serialize_color_alpha,
1717
};
18-
use cssparser::{match_ignore_ascii_case, CowRcStr, ParseError, Parser, ToCss, Token};
18+
use cssparser::{CowRcStr, ParseError, Parser, ToCss, Token, match_ignore_ascii_case};
1919
use std::f32::consts::PI;
2020
use std::fmt;
2121

@@ -54,14 +54,14 @@ where
5454
match *token {
5555
Token::Hash(ref value) | Token::IDHash(ref value) => {
5656
parse_hash_color(value.as_bytes()).map(|(r, g, b, a)| P::Output::from_rgba(r, g, b, a))
57-
}
57+
},
5858
Token::Ident(ref value) => parse_color_keyword(value),
5959
Token::Function(ref name) => {
6060
let name = name.clone();
6161
return input.parse_nested_block(|arguments| {
6262
parse_color_function(color_parser, name, arguments)
6363
});
64-
}
64+
},
6565
_ => Err(()),
6666
}
6767
.map_err(|()| location.new_unexpected_token_error(token.clone()))
@@ -178,14 +178,14 @@ where
178178
arguments.expect_comma()?;
179179
let blue = clamp_floor_256_f32(color_parser.parse_number(arguments)?);
180180
(red, green, blue)
181-
}
181+
},
182182
NumberOrPercentage::Percentage { unit_value } => {
183183
let red = clamp_unit_f32(unit_value);
184184
let green = clamp_unit_f32(color_parser.parse_percentage(arguments)?);
185185
arguments.expect_comma()?;
186186
let blue = clamp_unit_f32(color_parser.parse_percentage(arguments)?);
187187
(red, green, blue)
188-
}
188+
},
189189
};
190190

191191
let alpha = parse_legacy_alpha(color_parser, arguments)?;
@@ -1001,7 +1001,7 @@ pub trait ColorParser<'i> {
10011001
};
10021002

10031003
AngleOrNumber::Angle { degrees }
1004-
}
1004+
},
10051005
ref t => return Err(location.new_unexpected_token_error(t.clone())),
10061006
})
10071007
}
@@ -1081,7 +1081,7 @@ pub trait FromParsedColor {
10811081

10821082
/// Construct a new color from the `lab` notation.
10831083
fn from_lab(lightness: Option<f32>, a: Option<f32>, b: Option<f32>, alpha: Option<f32>)
1084-
-> Self;
1084+
-> Self;
10851085

10861086
/// Construct a new color from the `lch` notation.
10871087
fn from_lch(

color/tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
use super::*;
66
use cssparser::ParserInput;
7-
use serde_json::{json, Value};
7+
use serde_json::{Value, json};
88

99
fn 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
}

macros/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn parse_pat_to_table<'a>(
6666
if table[value as usize] == 0 {
6767
table[value as usize] = case_id;
6868
}
69-
}
69+
},
7070
syn::Pat::Range(syn::PatRange {
7171
ref start, ref end, ..
7272
}) => {
@@ -80,14 +80,14 @@ fn parse_pat_to_table<'a>(
8080
if table[hi as usize] == 0 {
8181
table[hi as usize] = case_id;
8282
}
83-
}
83+
},
8484
syn::Pat::Wild(_) => {
8585
for byte in table.iter_mut() {
8686
if *byte == 0 {
8787
*byte = case_id;
8888
}
8989
}
90-
}
90+
},
9191
syn::Pat::Ident(syn::PatIdent { ref ident, .. }) => {
9292
assert_eq!(*wildcard, None);
9393
*wildcard = Some(ident);
@@ -96,15 +96,15 @@ fn parse_pat_to_table<'a>(
9696
*byte = case_id;
9797
}
9898
}
99-
}
99+
},
100100
syn::Pat::Or(syn::PatOr { ref cases, .. }) => {
101101
for case in cases {
102102
parse_pat_to_table(case, case_id, wildcard, table);
103103
}
104-
}
104+
},
105105
_ => {
106106
panic!("Unexpected pattern: {:?}. Buggy code ?", pat);
107-
}
107+
},
108108
}
109109
}
110110

src/cow_rc_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl Clone for CowRcStr<'_> {
9393
let new_rc = rc.clone();
9494
mem::forget(rc); // Don’t actually take ownership of this strong reference
9595
CowRcStr::from_rc(new_rc)
96-
}
96+
},
9797
Ok(_) => CowRcStr { ..*self },
9898
}
9999
}

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ fn parse_border_spacing(_context: &ParserContext, input: &mut Parser)
6868
#![recursion_limit = "200"] // For color::parse_color_keyword
6969

7070
pub use crate::cow_rc_str::CowRcStr;
71-
pub use crate::from_bytes::{stylesheet_encoding, EncodingSupport};
71+
pub use crate::from_bytes::{EncodingSupport, stylesheet_encoding};
7272
#[doc(hidden)]
7373
pub use crate::macros::{
7474
_cssparser_internal_create_uninit_array, _cssparser_internal_to_lowercase,
7575
};
7676
pub use crate::nth::parse_nth;
7777
pub use crate::parser::{BasicParseError, BasicParseErrorKind, ParseError, ParseErrorKind};
7878
pub use crate::parser::{Delimiter, Delimiters, Parser, ParserInput, ParserState};
79-
pub use crate::rules_and_declarations::{parse_important, parse_one_declaration};
80-
pub use crate::rules_and_declarations::{parse_one_rule, StyleSheetParser};
8179
pub use crate::rules_and_declarations::{AtRuleParser, QualifiedRuleParser};
8280
pub use crate::rules_and_declarations::{DeclarationParser, RuleBodyItemParser, RuleBodyParser};
83-
pub use crate::serializer::{serialize_identifier, serialize_name, serialize_string};
81+
pub use crate::rules_and_declarations::{StyleSheetParser, parse_one_rule};
82+
pub use crate::rules_and_declarations::{parse_important, parse_one_declaration};
8483
pub use crate::serializer::{CssStringWriter, ToCss, TokenSerializationType};
84+
pub use crate::serializer::{serialize_identifier, serialize_name, serialize_string};
8585
pub use crate::tokenizer::{SourceLocation, SourcePosition, Token};
8686
pub use crate::unicode_range::UnicodeRange;
8787
pub use cssparser_macros::*;
@@ -102,7 +102,7 @@ mod parser;
102102
mod serializer;
103103
mod unicode_range;
104104

105-
#[cfg(all(test,target_pointer_width = "64"))]
105+
#[cfg(all(test, target_pointer_width = "64"))]
106106
mod size_of_tests;
107107
#[cfg(test)]
108108
mod tests;

src/nth.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn parse_nth<'i>(input: &mut Parser<'i, '_>) -> Result<(i32, i32), BasicPars
3030
}
3131
}
3232
}
33-
}
33+
},
3434
Token::Ident(ref value) => {
3535
match_ignore_ascii_case! { value,
3636
"even" => Ok((2, 0)),
@@ -54,7 +54,7 @@ pub fn parse_nth<'i>(input: &mut Parser<'i, '_>) -> Result<(i32, i32), BasicPars
5454
}
5555
}
5656
}
57-
}
57+
},
5858
Token::Delim('+') => match *input.next_including_whitespace()? {
5959
Token::Ident(ref value) => {
6060
match_ignore_ascii_case! { value,
@@ -68,16 +68,16 @@ pub fn parse_nth<'i>(input: &mut Parser<'i, '_>) -> Result<(i32, i32), BasicPars
6868
}
6969
}
7070
}
71-
}
71+
},
7272
ref token => {
7373
let token = token.clone();
7474
Err(input.new_basic_unexpected_token_error(token))
75-
}
75+
},
7676
},
7777
ref token => {
7878
let token = token.clone();
7979
Err(input.new_basic_unexpected_token_error(token))
80-
}
80+
},
8181
}
8282
}
8383

@@ -94,7 +94,7 @@ fn parse_b<'i>(input: &mut Parser<'i, '_>, a: i32) -> Result<(i32, i32), BasicPa
9494
_ => {
9595
input.reset(&start);
9696
Ok((a, 0))
97-
}
97+
},
9898
}
9999
}
100100

src/parser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ impl fmt::Display for BasicParseErrorKind<'_> {
8181
match self {
8282
BasicParseErrorKind::UnexpectedToken(token) => {
8383
write!(f, "unexpected token: {token:?}")
84-
}
84+
},
8585
BasicParseErrorKind::EndOfInput => write!(f, "unexpected end of input"),
8686
BasicParseErrorKind::AtRuleInvalid(rule) => {
8787
write!(f, "invalid @ rule encountered: '@{rule}'")
88-
}
88+
},
8989
BasicParseErrorKind::AtRuleBodyInvalid => write!(f, "invalid @ rule body encountered"),
9090
BasicParseErrorKind::QualifiedRuleInvalid => {
9191
write!(f, "invalid qualified rule encountered")
92-
}
92+
},
9393
}
9494
}
9595
}
@@ -621,7 +621,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
621621
loop {
622622
match self.next_including_whitespace_and_comments() {
623623
Err(e) => return Err(e),
624-
Ok(&Token::Comment(_)) => {}
624+
Ok(&Token::Comment(_)) => {},
625625
_ => break,
626626
}
627627
}
@@ -752,7 +752,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
752752
match self.parse_until_before(Delimiter::Comma, &mut parse_one) {
753753
Ok(v) => values.push(v),
754754
Err(e) if !ignore_errors => return Err(e),
755-
Err(_) => {}
755+
Err(_) => {},
756756
}
757757
match self.next() {
758758
Err(_) => return Ok(values),
@@ -1035,7 +1035,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
10351035
let token = t.clone();
10361036
return Err(self.new_basic_unexpected_token_error(token));
10371037
}
1038-
}
1038+
},
10391039
Err(_) => return Ok(()),
10401040
}
10411041
}

src/rules_and_declarations.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use super::{BasicParseError, BasicParseErrorKind, Delimiter, ParseError, Parser, Token};
88
use crate::cow_rc_str::CowRcStr;
9-
use crate::parser::{parse_nested_block, parse_until_after, ParseUntilErrorBehavior, ParserState};
9+
use crate::parser::{ParseUntilErrorBehavior, ParserState, parse_nested_block, parse_until_after};
1010

1111
/// Parse `!important`.
1212
///
@@ -260,7 +260,7 @@ where
260260
Token::AtKeyword(ref name) => {
261261
let name = name.clone();
262262
return Some(parse_at_rule(&start, name, self.input, &mut *self.parser));
263-
}
263+
},
264264
// https://drafts.csswg.org/css-syntax/#consume-a-declaration bails out just to
265265
// keep parsing as a qualified rule if the token is not an ident, so we implement
266266
// that in a slightly more straight-forward way
@@ -299,7 +299,7 @@ where
299299
}
300300

301301
return Some(result.map_err(|e| (e, self.input.slice_from(start.position()))));
302-
}
302+
},
303303
token => {
304304
let result = if self.parser.parse_qualified() {
305305
self.input.reset(&start);
@@ -312,7 +312,7 @@ where
312312
})
313313
};
314314
return Some(result.map_err(|e| (e, self.input.slice_from(start.position()))));
315-
}
315+
},
316316
}
317317
}
318318
}
@@ -367,7 +367,7 @@ where
367367
_ => {
368368
self.input.reset(&start);
369369
None
370-
}
370+
},
371371
},
372372
_ => None,
373373
};
@@ -438,7 +438,7 @@ where
438438
_ => {
439439
input.reset(&start);
440440
None
441-
}
441+
},
442442
}
443443
} else {
444444
None
@@ -471,19 +471,19 @@ where
471471
.map_err(|()| input.new_unexpected_token_error(Token::Semicolon)),
472472
Ok(&Token::CurlyBracketBlock) => {
473473
parse_nested_block(input, |input| parser.parse_block(prelude, start, input))
474-
}
474+
},
475475
Ok(_) => unreachable!(),
476476
};
477477
result.map_err(|e| (e, input.slice_from(start.position())))
478-
}
478+
},
479479
Err(error) => {
480480
let end_position = input.position();
481481
match input.next() {
482-
Ok(&Token::CurlyBracketBlock) | Ok(&Token::Semicolon) | Err(_) => {}
482+
Ok(&Token::CurlyBracketBlock) | Ok(&Token::Semicolon) | Err(_) => {},
483483
_ => unreachable!(),
484484
};
485485
Err((error, input.slice(start.position()..end_position)))
486-
}
486+
},
487487
}
488488
}
489489

0 commit comments

Comments
 (0)