Skip to content

Commit c6fc7d4

Browse files
committed
Run cargo fmt on all files
1 parent 171ee21 commit c6fc7d4

File tree

9 files changed

+51
-43
lines changed

9 files changed

+51
-43
lines changed

color/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ where
5555
let token = input.next()?;
5656
match *token {
5757
Token::Hash(ref value) | Token::IDHash(ref value) => {
58-
parse_hash_color(value.as_bytes()).map(|(r, g, b, a)| {
59-
P::Output::from_rgba(r, g, b, a)
60-
})
61-
},
58+
parse_hash_color(value.as_bytes()).map(|(r, g, b, a)| P::Output::from_rgba(r, g, b, a))
59+
}
6260
Token::Ident(ref value) => parse_color_keyword(value),
6361
Token::Function(ref name) => {
6462
let name = name.clone();

color/tests.rs

+17-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
use super::*;
6-
use crate::{ColorParser, PredefinedColorSpace, Color, RgbaLegacy};
6+
use crate::{Color, ColorParser, PredefinedColorSpace, RgbaLegacy};
77
use cssparser::{Parser, ParserInput};
88
use serde_json::{self, json, Value};
99

@@ -43,7 +43,6 @@ fn assert_json_eq(results: Value, expected: Value, message: &str) {
4343
}
4444
}
4545

46-
4746
fn run_raw_json_tests<F: Fn(Value, Value) -> ()>(json_data: &str, run: F) {
4847
let items = match serde_json::from_str(json_data) {
4948
Ok(Value::Array(items)) => items,
@@ -92,11 +91,14 @@ fn color3() {
9291
#[cfg_attr(all(miri, feature = "skip_long_tests"), ignore)]
9392
#[test]
9493
fn color3_hsl() {
95-
run_color_tests(include_str!("../src/css-parsing-tests/color3_hsl.json"), |c| {
96-
c.ok()
97-
.map(|v| v.to_css_string().to_json())
98-
.unwrap_or(Value::Null)
99-
})
94+
run_color_tests(
95+
include_str!("../src/css-parsing-tests/color3_hsl.json"),
96+
|c| {
97+
c.ok()
98+
.map(|v| v.to_css_string().to_json())
99+
.unwrap_or(Value::Null)
100+
},
101+
)
100102
}
101103

102104
/// color3_keywords.json is different: R, G and B are in 0..255 rather than 0..1
@@ -115,11 +117,14 @@ fn color3_keywords() {
115117
#[cfg_attr(all(miri, feature = "skip_long_tests"), ignore)]
116118
#[test]
117119
fn color4_hwb() {
118-
run_color_tests(include_str!("../src/css-parsing-tests/color4_hwb.json"), |c| {
119-
c.ok()
120-
.map(|v| v.to_css_string().to_json())
121-
.unwrap_or(Value::Null)
122-
})
120+
run_color_tests(
121+
include_str!("../src/css-parsing-tests/color4_hwb.json"),
122+
|c| {
123+
c.ok()
124+
.map(|v| v.to_css_string().to_json())
125+
.unwrap_or(Value::Null)
126+
},
127+
)
123128
}
124129

125130
#[cfg_attr(all(miri, feature = "skip_long_tests"), ignore)]

macros/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ fn get_byte_from_lit(lit: &syn::Lit) -> u8 {
4848

4949
fn get_byte_from_expr_lit(expr: &syn::Expr) -> u8 {
5050
match *expr {
51-
syn::Expr::Lit(syn::ExprLit { ref lit, .. }) => {
52-
get_byte_from_lit(lit)
53-
}
51+
syn::Expr::Lit(syn::ExprLit { ref lit, .. }) => get_byte_from_lit(lit),
5452
_ => unreachable!(),
5553
}
5654
}
@@ -69,7 +67,9 @@ fn parse_pat_to_table<'a>(
6967
table[value as usize] = case_id;
7068
}
7169
}
72-
&syn::Pat::Range(syn::PatRange { ref start, ref end, .. }) => {
70+
&syn::Pat::Range(syn::PatRange {
71+
ref start, ref end, ..
72+
}) => {
7373
let lo = get_byte_from_expr_lit(&start.as_ref().unwrap());
7474
let hi = get_byte_from_expr_lit(&end.as_ref().unwrap());
7575
for value in lo..hi {

src/cow_rc_str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use std::borrow::{Borrow, Cow};
66
use std::rc::Rc;
7-
use std::{cmp, fmt, hash, marker, mem, ops, slice, str, ptr};
7+
use std::{cmp, fmt, hash, marker, mem, ops, ptr, slice, str};
88

99
/// A string that is either shared (heap-allocated and reference-counted) or borrowed.
1010
///

src/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
748748
match self.parse_until_before(Delimiter::Comma, &mut parse_one) {
749749
Ok(v) => values.push(v),
750750
Err(e) if !ignore_errors => return Err(e),
751-
Err(_) => {},
751+
Err(_) => {}
752752
}
753753
match self.next() {
754754
Err(_) => return Ok(values),

src/rules_and_declarations.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,10 @@ where
253253
self.input.skip_whitespace();
254254
let start = self.input.state();
255255
match self.input.next_including_whitespace_and_comments().ok()? {
256-
Token::CloseCurlyBracket |
257-
Token::WhiteSpace(..) |
258-
Token::Semicolon |
259-
Token::Comment(..) => continue,
256+
Token::CloseCurlyBracket
257+
| Token::WhiteSpace(..)
258+
| Token::Semicolon
259+
| Token::Comment(..) => continue,
260260
Token::AtKeyword(ref name) => {
261261
let name = name.clone();
262262
return Some(parse_at_rule(&start, name, self.input, &mut *self.parser));
@@ -294,7 +294,7 @@ where
294294
&mut *self.parser,
295295
Delimiter::Semicolon | Delimiter::CurlyBracketBlock,
296296
) {
297-
return Some(Ok(qual))
297+
return Some(Ok(qual));
298298
}
299299
}
300300

src/serializer.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ where
4949
dtoa_short::write(dest, value)?
5050
};
5151

52-
if int_value.is_none() && value.fract() == 0. && !notation.decimal_point && !notation.scientific {
52+
if int_value.is_none() && value.fract() == 0. && !notation.decimal_point && !notation.scientific
53+
{
5354
dest.write_str(".0")?;
5455
}
5556
Ok(())

src/tests.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#[cfg(feature = "bench")]
66
extern crate test;
77

8-
98
use serde_json::{self, json, Map, Value};
109

1110
#[cfg(feature = "bench")]
@@ -35,10 +34,7 @@ fn almost_equals(a: &Value, b: &Value) -> bool {
3534
(&Value::Bool(a), &Value::Bool(b)) => a == b,
3635
(Value::String(a), Value::String(b)) => a == b,
3736
(Value::Array(a), Value::Array(b)) => {
38-
a.len() == b.len()
39-
&& a.iter()
40-
.zip(b.iter())
41-
.all(|(a, b)| almost_equals(a, b))
37+
a.len() == b.len() && a.iter().zip(b.iter()).all(|(a, b)| almost_equals(a, b))
4238
}
4339
(&Value::Object(_), &Value::Object(_)) => panic!("Not implemented"),
4440
(&Value::Null, &Value::Null) => true,
@@ -433,8 +429,7 @@ fn serializer(preserve_comments: bool) {
433429
preserve_comments: bool,
434430
) {
435431
while let Ok(token) = if preserve_comments {
436-
input
437-
.next_including_whitespace_and_comments().cloned()
432+
input.next_including_whitespace_and_comments().cloned()
438433
} else {
439434
input.next_including_whitespace().cloned()
440435
} {
@@ -592,8 +587,6 @@ fn line_numbers() {
592587

593588
#[test]
594589
fn overflow() {
595-
596-
597590
let css = r"
598591
2147483646
599592
2147483647

src/tokenizer.rs

+17-6
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ impl<'a> Tokenizer<'a> {
255255

256256
#[inline]
257257
pub fn see_function(&mut self, name: &str) {
258-
if self.var_or_env_functions == SeenStatus::LookingForThem && (name.eq_ignore_ascii_case("var") || name.eq_ignore_ascii_case("env")) {
258+
if self.var_or_env_functions == SeenStatus::LookingForThem
259+
&& (name.eq_ignore_ascii_case("var") || name.eq_ignore_ascii_case("env"))
260+
{
259261
self.var_or_env_functions = SeenStatus::SeenAtLeastOne;
260262
}
261263
}
@@ -320,10 +322,12 @@ impl<'a> Tokenizer<'a> {
320322

321323
pub fn current_source_line(&self) -> &'a str {
322324
let current = self.position();
323-
let start = self.slice(SourcePosition(0)..current)
325+
let start = self
326+
.slice(SourcePosition(0)..current)
324327
.rfind(|c| matches!(c, '\r' | '\n' | '\x0C'))
325328
.map_or(0, |start| start + 1);
326-
let end = self.slice(current..SourcePosition(self.input.len()))
329+
let end = self
330+
.slice(current..SourcePosition(self.input.len()))
327331
.find(|c| matches!(c, '\r' | '\n' | '\x0C'))
328332
.map_or(self.input.len(), |end| current.0 + end);
329333
self.slice(SourcePosition(start)..SourcePosition(end))
@@ -422,7 +426,10 @@ impl<'a> Tokenizer<'a> {
422426

423427
#[inline]
424428
fn next_char(&self) -> char {
425-
unsafe { self.input.get_unchecked(self.position().0..) }.chars().next().unwrap()
429+
unsafe { self.input.get_unchecked(self.position().0..) }
430+
.chars()
431+
.next()
432+
.unwrap()
426433
}
427434

428435
// Given that a newline has been seen, advance over the newline
@@ -1052,9 +1059,13 @@ fn consume_numeric<'a>(tokenizer: &mut Tokenizer<'a>) -> Token<'a> {
10521059

10531060
let mut value = sign * (integral_part + fractional_part);
10541061

1055-
if tokenizer.has_at_least(1) && matches!(tokenizer.next_byte_unchecked(), b'e' | b'E') && (tokenizer.byte_at(1).is_ascii_digit() || (tokenizer.has_at_least(2)
1062+
if tokenizer.has_at_least(1)
1063+
&& matches!(tokenizer.next_byte_unchecked(), b'e' | b'E')
1064+
&& (tokenizer.byte_at(1).is_ascii_digit()
1065+
|| (tokenizer.has_at_least(2)
10561066
&& matches!(tokenizer.byte_at(1), b'+' | b'-')
1057-
&& tokenizer.byte_at(2).is_ascii_digit())) {
1067+
&& tokenizer.byte_at(2).is_ascii_digit()))
1068+
{
10581069
is_integer = false;
10591070
tokenizer.advance(1);
10601071
let (has_sign, sign) = match tokenizer.next_byte_unchecked() {

0 commit comments

Comments
 (0)