@@ -50,7 +50,8 @@ let html: &str = r#"
50
50
let tree : Html = Html :: parse (html ). expect (" Invalid HTML" );
51
51
52
52
// Now you can use it!
53
- // Beware, this doesn't always work as you can have ways to write the same HTML.
53
+ // Beware, this doesn't always work as you can have
54
+ // difference ways to write the same HTML.
54
55
assert! (format! (" {tree}" ) == html );
55
56
```
56
57
@@ -81,10 +82,10 @@ let html: &str = r##"
81
82
let filter = Filter :: new (). tag_name (" li" );
82
83
83
84
// Parse your HTML
84
- let filtered_tree : Html = Html :: parse (html ). expect (" Invalid HTML" ). filter (& filter );
85
+ let filtered : Html = Html :: parse (html ). expect (" Invalid HTML" ). filter (& filter );
85
86
86
- // Check the result: filtered_tree contains the 4 lis from the above HTML string
87
- if let Html :: Vec (links ) = filtered_tree {
87
+ // `filtered` contains the 4 `<li>`s from the above HTML string
88
+ if let Html :: Vec (links ) = filtered {
88
89
assert! (links . len () == 4 )
89
90
} else {
90
91
unreachable! ()
@@ -119,12 +120,8 @@ let filter = Filter::new().tag_name("a");
119
120
let link : Html = Html :: parse (html ). expect (" Invalid HTML" ). find (& filter );
120
121
121
122
// Check the result: link contains `<a href="/home">Home</a>`
122
- if let Html :: Tag { tag , child , .. } = link {
123
- if let Html :: Text (text ) = * child {
124
- assert! (tag . as_name () == " a" && text == " Home" );
125
- } else {
126
- unreachable! ()
127
- }
123
+ if let Html :: Tag { tag , child , .. } = link && let Html :: Text (text ) = * child {
124
+ assert! (tag . as_name () == " a" && text == " Home" );
128
125
} else {
129
126
unreachable! ()
130
127
}
@@ -134,8 +131,8 @@ if let Html::Tag { tag, child, .. } = link {
134
131
135
132
Licensed under either of
136
133
137
- - [ Apache License, Version 2.0] ( LICENSE-APACHE )
138
- - [ MIT license] ( LICENSE-MIT )
134
+ - [ Apache License, Version 2.0] ( LICENSE-APACHE )
135
+ - [ MIT license] ( LICENSE-MIT )
139
136
140
137
at your option.
141
138
0 commit comments