Skip to content

Commit 8327eda

Browse files
mina86adamreichold
authored andcommitted
Fix clippy warnings
1 parent a99da69 commit 8327eda

File tree

7 files changed

+25
-26
lines changed

7 files changed

+25
-26
lines changed

scraper/examples/document.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() {
2020
stdin.read_to_string(&mut input).unwrap();
2121
let document = Html::parse_document(&input);
2222

23-
println!("{:#?}", document);
23+
println!("{document:#?}");
2424

2525
for node in document.select(&selector) {
2626
println!("{:?}", node.value());

scraper/examples/fragment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() {
2020
stdin.read_to_string(&mut input).unwrap();
2121
let fragment = Html::parse_fragment(&input);
2222

23-
println!("{:#?}", fragment);
23+
println!("{fragment:#?}");
2424

2525
for node in fragment.select(&selector) {
2626
println!("{:?}", node.value());

scraper/src/error.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Display for SelectorErrorKind<'_> {
8383
format!("Token {:?} was not expected", utils::render_token(token))
8484
}
8585
Self::EndOfLine => "Unexpected EOL".to_string(),
86-
Self::InvalidAtRule(rule) => format!("Invalid @-rule {:?}", rule),
86+
Self::InvalidAtRule(rule) => format!("Invalid @-rule {rule:?}"),
8787
Self::InvalidAtRuleBody => "The body of an @-rule was invalid".to_string(),
8888
Self::QualRuleInvalid => "The qualified name was invalid".to_string(),
8989
Self::ExpectedColonOnPseudoElement(token) => format!(
@@ -95,8 +95,7 @@ impl Display for SelectorErrorKind<'_> {
9595
utils::render_token(token)
9696
),
9797
Self::UnexpectedSelectorParseError(err) => format!(
98-
"Unexpected error occurred. Please report this to the developer\n{:#?}",
99-
err
98+
"Unexpected error occurred. Please report this to the developer\n{err:#?}"
10099
),
101100
}
102101
)

scraper/src/error/utils.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use cssparser::Token;
33
pub(crate) fn render_token(token: &Token<'_>) -> String {
44
match token {
55
Token::Ident(ident) => ident.to_string(),
6-
Token::AtKeyword(value) => format!("@{}", value),
7-
Token::Hash(name) | Token::IDHash(name) => format!("#{}", name),
8-
Token::QuotedString(value) => format!("\"{}\"", value),
6+
Token::AtKeyword(value) => format!("@{value}"),
7+
Token::Hash(name) | Token::IDHash(name) => format!("#{name}"),
8+
Token::QuotedString(value) => format!("\"{value}\""),
99
Token::UnquotedUrl(value) => value.to_string(),
1010
Token::Number {
1111
has_sign: signed,
@@ -24,10 +24,10 @@ pub(crate) fn render_token(token: &Token<'_>) -> String {
2424
unit,
2525
} => format!("{}{}", render_int(*signed, *num), unit),
2626
Token::WhiteSpace(_) => String::from(" "),
27-
Token::Comment(comment) => format!("/* {} */", comment),
28-
Token::Function(name) => format!("{}()", name),
29-
Token::BadString(string) => format!("<Bad String {:?}>", string),
30-
Token::BadUrl(url) => format!("<Bad URL {:?}>", url),
27+
Token::Comment(comment) => format!("/* {comment} */"),
28+
Token::Function(name) => format!("{name}()"),
29+
Token::BadString(string) => format!("<Bad String {string:?}>"),
30+
Token::BadUrl(url) => format!("<Bad URL {url:?}>"),
3131
// Single-character token
3232
Token::Colon => ":".into(),
3333
Token::Semicolon => ";".into(),
@@ -54,7 +54,7 @@ fn render_number(signed: bool, num: f32, token: &Token) -> String {
5454

5555
match token {
5656
Token::Number { .. } => num,
57-
Token::Percentage { .. } => format!("{}%", num),
57+
Token::Percentage { .. } => format!("{num}%"),
5858
_ => panic!("render_number is not supposed to be called on a non-numerical token"),
5959
}
6060
}
@@ -69,14 +69,14 @@ fn render_int(signed: bool, num: f32) -> String {
6969

7070
fn render_int_signed(num: f32) -> String {
7171
if num > 0.0 {
72-
format!("+{}", num)
72+
format!("+{num}")
7373
} else {
74-
format!("-{}", num)
74+
format!("-{num}")
7575
}
7676
}
7777

7878
fn render_int_unsigned(num: f32) -> String {
79-
format!("{}", num)
79+
format!("{num}")
8080
}
8181

8282
#[cfg(test)]

scraper/src/html/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl Html {
104104
}
105105

106106
/// Returns the root `<html>` element.
107-
pub fn root_element(&self) -> ElementRef {
107+
pub fn root_element(&self) -> ElementRef<'_> {
108108
let root_node = self
109109
.tree
110110
.root()

scraper/src/node.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ impl fmt::Debug for Node {
114114
match *self {
115115
Node::Document => write!(f, "Document"),
116116
Node::Fragment => write!(f, "Fragment"),
117-
Node::Doctype(ref d) => write!(f, "Doctype({:?})", d),
118-
Node::Comment(ref c) => write!(f, "Comment({:?})", c),
119-
Node::Text(ref t) => write!(f, "Text({:?})", t),
120-
Node::Element(ref e) => write!(f, "Element({:?})", e),
121-
Node::ProcessingInstruction(ref pi) => write!(f, "ProcessingInstruction({:?})", pi),
117+
Node::Doctype(ref d) => write!(f, "Doctype({d:?})"),
118+
Node::Comment(ref c) => write!(f, "Comment({c:?})"),
119+
Node::Text(ref t) => write!(f, "Text({t:?})"),
120+
Node::Element(ref e) => write!(f, "Element({e:?})"),
121+
Node::ProcessingInstruction(ref pi) => write!(f, "ProcessingInstruction({pi:?})"),
122122
}
123123
}
124124
}
@@ -275,7 +275,7 @@ impl Element {
275275
}
276276

277277
/// Returns an iterator over the element's classes.
278-
pub fn classes(&self) -> Classes {
278+
pub fn classes(&self) -> Classes<'_> {
279279
let classes = self.classes.get_or_init(|| {
280280
let mut classes = self
281281
.attrs
@@ -313,7 +313,7 @@ impl Element {
313313
}
314314

315315
/// Returns an iterator over the element's attributes.
316-
pub fn attrs(&self) -> Attrs {
316+
pub fn attrs(&self) -> Attrs<'_> {
317317
Attrs {
318318
inner: self.attrs.iter(),
319319
}
@@ -362,7 +362,7 @@ impl fmt::Debug for Element {
362362
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
363363
write!(f, "<{}", self.name())?;
364364
for (key, value) in self.attrs() {
365-
write!(f, " {}={:?}", key, value)?;
365+
write!(f, " {key}={value:?}")?;
366366
}
367367
write!(f, ">")
368368
}

scraper/src/selector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct Selector {
2828

2929
impl Selector {
3030
/// Parses a CSS selector group.
31-
pub fn parse(selectors: &'_ str) -> Result<Self, SelectorErrorKind> {
31+
pub fn parse(selectors: &str) -> Result<Self, SelectorErrorKind<'_>> {
3232
let mut parser_input = cssparser::ParserInput::new(selectors);
3333
let mut parser = cssparser::Parser::new(&mut parser_input);
3434

0 commit comments

Comments
 (0)