Skip to content

Run clippy #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ rust:
- stable
- beta
- nightly
- 1.36.0

matrix:
allow_failures:
- rust: nightly
11 changes: 4 additions & 7 deletions src/element_ref/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct ElementRef<'a> {

impl<'a> ElementRef<'a> {
fn new(node: NodeRef<'a, Node>) -> Self {
ElementRef { node: node }
ElementRef { node }
}

/// Wraps a `NodeRef` only if it references a `Node::Element`.
Expand All @@ -42,16 +42,13 @@ impl<'a> ElementRef<'a> {
let mut inner = self.traverse();
inner.next(); // Skip Edge::Open(self).

Select {
inner: inner,
selector: selector,
}
Select { inner, selector }
}

fn serialize(&self, traversal_scope: TraversalScope) -> String {
let opts = SerializeOpts {
scripting_enabled: false, // It's not clear what this does.
traversal_scope: traversal_scope,
traversal_scope,
create_missing_parent: false,
};
let mut buf = Vec::new();
Expand Down Expand Up @@ -120,7 +117,7 @@ impl<'a> Iterator for Text<'a> {
fn next(&mut self) -> Option<&'a str> {
for edge in &mut self.inner {
if let Edge::Open(node) = edge {
if let &Node::Text(ref text) = node.value() {
if let Node::Text(ref text) = node.value() {
return Some(&*text);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Html {
pub fn select<'a, 'b>(&'a self, selector: &'b Selector) -> Select<'a, 'b> {
Select {
inner: self.tree.nodes(),
selector: selector,
selector,
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/html/tree_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ impl TreeSink for Html {
system_id: StrTendril,
) {
let doctype = Doctype {
name: name,
public_id: public_id,
system_id: system_id,
name,
public_id,
system_id,
};
self.tree.root_mut().append(Node::Doctype(doctype));
}
Expand Down Expand Up @@ -117,7 +117,7 @@ impl TreeSink for Html {
_ => unreachable!(),
}
} else {
parent.append(Node::Text(Text { text: text }));
parent.append(Node::Text(Text { text }));
}
}
}
Expand All @@ -141,7 +141,7 @@ impl TreeSink for Html {
}

let mut sibling = self.tree.get_mut(*sibling).unwrap();
if !sibling.parent().is_none() {
if sibling.parent().is_some() {
match new_node {
NodeOrText::AppendNode(id) => {
sibling.insert_id_before(id);
Expand All @@ -159,7 +159,7 @@ impl TreeSink for Html {
_ => unreachable!(),
}
} else {
sibling.insert_before(Node::Text(Text { text: text }));
sibling.insert_before(Node::Text(Text { text }));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ fn main() {
query(&input, &output, &selector, &mut io::stdin())
} else {
files
.into_iter()
.iter()
.map(File::open)
.map(Result::unwrap)
.map(|mut f| query(&input, &output, &selector, &mut f))
.fold(false, |a, m| a || m)
.any(|m| m)
};

process::exit(if matched { 0 } else { 1 });
Expand Down
7 changes: 3 additions & 4 deletions src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::fmt;

use smallvec::SmallVec;

use cssparser;
use html5ever::{LocalName, Namespace};
use selectors::parser::SelectorParseErrorKind;
use selectors::{matching, parser, visitor};
Expand All @@ -23,9 +22,9 @@ pub struct Selector {
impl Selector {
/// Parses a CSS selector group.

pub fn parse<'t, 'i>(
selectors: &'i str,
) -> Result<Self, cssparser::ParseError<'i, SelectorParseErrorKind<'i>>> {
pub fn parse(
selectors: &'_ str,
) -> Result<Self, cssparser::ParseError<'_, SelectorParseErrorKind<'_>>> {
let mut parser_input = cssparser::ParserInput::new(selectors);
let mut parser = cssparser::Parser::new(&mut parser_input);
parser::SelectorList::parse(&Parser, &mut parser).map(|list| Selector { selectors: list.0 })
Expand Down