Skip to content

Commit 551b76a

Browse files
authored
Merge pull request #69 from causal-agent/update-deps
Update dependencies
2 parents 32956c4 + a34dda3 commit 551b76a

File tree

7 files changed

+19
-30
lines changed

7 files changed

+19
-30
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
target
22
*.bk
33
Cargo.lock
4+
.idea

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "scraper"
33
version = "0.12.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
description = "HTML parsing and querying with CSS selectors"
77
keywords = ["html", "css", "selector", "scraping"]

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# scraper
22

3+
[![crates.io package](https://repology.org/badge/version-for-repo/crates_io/rust:scraper.svg)](https://repology.org/project/rust:scraper/versions)
4+
![test](https://github.com/causal-agent/scraper/actions/workflows/test.yml/badge.svg)
35
[![Join the chat at https://gitter.im/scraper-rs/community](https://badges.gitter.im/scraper-rs/community.svg)](https://gitter.im/scraper-rs/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
46

57
HTML parsing and querying with CSS selectors.
@@ -127,10 +129,14 @@ let text = h1.text().collect::<Vec<_>>();
127129
assert_eq!(vec!["Hello, ", "world!"], text);
128130
```
129131

130-
# Contributing
132+
## Contributing
131133

132134
Please feel free to open pull requests. If you're planning on implementing
133135
something big (i.e. not fixing a typo, a small bug fix, minor refactor, etc)
134136
then please open an issue first.
135137

138+
## Stargazers over time
139+
140+
[![Stargazers over time](https://starchart.cc/causal-agent/scraper.svg)](https://starchart.cc/causal-agent/scraper)
141+
136142
License: ISC

src/element_ref/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a> ElementRef<'a> {
4343
inner.next(); // Skip Edge::Open(self).
4444

4545
Select {
46-
scope: self.clone(),
46+
scope: *self,
4747
inner,
4848
selector,
4949
}

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn main() {
7070
let args: Vec<String> = env::args().collect();
7171
let matches = match opts.parse(&args[1..]) {
7272
Ok(m) => m,
73-
Err(f) => panic!(f.to_string()),
73+
Err(f) => panic!("{}", f.to_string()),
7474
};
7575
if matches.opt_present("h") {
7676
print!(

src/node.rs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,50 +38,32 @@ pub enum Node {
3838
impl Node {
3939
/// Returns true if node is the document root.
4040
pub fn is_document(&self) -> bool {
41-
match *self {
42-
Node::Document => true,
43-
_ => false,
44-
}
41+
matches!(*self, Node::Document)
4542
}
4643

4744
/// Returns true if node is the fragment root.
4845
pub fn is_fragment(&self) -> bool {
49-
match *self {
50-
Node::Fragment => true,
51-
_ => false,
52-
}
46+
matches!(*self, Node::Fragment)
5347
}
5448

5549
/// Returns true if node is a doctype.
5650
pub fn is_doctype(&self) -> bool {
57-
match *self {
58-
Node::Doctype(_) => true,
59-
_ => false,
60-
}
51+
matches!(*self, Node::Doctype(_))
6152
}
6253

6354
/// Returns true if node is a comment.
6455
pub fn is_comment(&self) -> bool {
65-
match *self {
66-
Node::Comment(_) => true,
67-
_ => false,
68-
}
56+
matches!(*self, Node::Comment(_))
6957
}
7058

7159
/// Returns true if node is text.
7260
pub fn is_text(&self) -> bool {
73-
match *self {
74-
Node::Text(_) => true,
75-
_ => false,
76-
}
61+
matches!(*self, Node::Text(_))
7762
}
7863

7964
/// Returns true if node is an element.
8065
pub fn is_element(&self) -> bool {
81-
match *self {
82-
Node::Element(_) => true,
83-
_ => false,
84-
}
66+
matches!(*self, Node::Element(_))
8567
}
8668

8769
/// Returns self as a doctype.
@@ -284,7 +266,7 @@ impl Element {
284266

285267
/// Returns the element ID.
286268
pub fn id(&self) -> Option<&str> {
287-
self.id.as_ref().map(Deref::deref)
269+
self.id.as_deref()
288270
}
289271

290272
/// Returns true if element has the class.

src/selector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl Selector {
4949
context.scope_element = scope.map(|x| selectors::Element::opaque(&x));
5050
self.selectors
5151
.iter()
52-
.any(|s| matching::matches_selector(&s, 0, None, element, &mut context, &mut |_, _| {}))
52+
.any(|s| matching::matches_selector(s, 0, None, element, &mut context, &mut |_, _| {}))
5353
}
5454
}
5555

0 commit comments

Comments
 (0)