Skip to content

Commit 7f89c1d

Browse files
committed
format code using clippy
1 parent 5c5672d commit 7f89c1d

File tree

9 files changed

+64
-66
lines changed

9 files changed

+64
-66
lines changed

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Output {
4646
}
4747
}
4848

49-
const ASCII: &'static str = " \
49+
const ASCII: &str = " \
5050
_____ ______________ __________ ___________________ ___
5151
| \\ / \\ | | | | | |
5252
| \\_/ __ \\_| __ | | ___ ___ |__| |
@@ -57,7 +57,7 @@ const ASCII: &'static str = " \
5757
";
5858
const CACHE_ASSET_FILE_SIZE_THRESHOLD: usize = 1024 * 50; // Minimum file size for on-disk caching (in bytes)
5959
const DEFAULT_NETWORK_TIMEOUT: u64 = 120;
60-
const DEFAULT_USER_AGENT: &'static str =
60+
const DEFAULT_USER_AGENT: &str =
6161
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0";
6262
const ENV_VAR_NO_COLOR: &str = "NO_COLOR";
6363
const ENV_VAR_TERM: &str = "TERM";
@@ -135,7 +135,7 @@ fn main() {
135135
options.encoding = Some(encoding.to_string());
136136
}
137137
if let Some(domains) = app.get_many::<String>("domains") {
138-
let list_of_domains: Vec<String> = domains.map(|v| v.clone()).collect::<Vec<_>>();
138+
let list_of_domains: Vec<String> = domains.cloned().collect::<Vec<_>>();
139139
options.domains = Some(list_of_domains);
140140
}
141141
options.ignore_errors = app.is_present("ignore-errors");

tests/cli/basic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ mod passing {
9595
{file_url_css}\n\
9696
{file_url_css}\n\
9797
",
98-
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
99-
file_url_css = Url::from_file_path(fs::canonicalize(&path_css).unwrap()).unwrap(),
98+
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
99+
file_url_css = Url::from_file_path(fs::canonicalize(path_css).unwrap()).unwrap(),
100100
)
101101
);
102102

tests/cli/local_files.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mod passing {
8888
String::from_utf8_lossy(&out.stderr),
8989
format!(
9090
"{file_url_html}\n",
91-
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
91+
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
9292
)
9393
);
9494

@@ -188,8 +188,8 @@ mod passing {
188188
{file_url_html}\n\
189189
{file_url_svg}\n\
190190
",
191-
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
192-
file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(),
191+
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
192+
file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(),
193193
)
194194
);
195195

tests/cli/noscript.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ mod passing {
3030
{file_url_html}\n\
3131
{file_url_svg}\n\
3232
",
33-
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
34-
file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(),
33+
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
34+
file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(),
3535
)
3636
);
3737

@@ -61,8 +61,8 @@ mod passing {
6161
{file_url_html}\n\
6262
{file_url_svg}\n\
6363
",
64-
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
65-
file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(),
64+
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
65+
file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(),
6666
)
6767
);
6868

@@ -92,8 +92,8 @@ mod passing {
9292
{file_url_html}\n\
9393
{file_url_svg}\n\
9494
",
95-
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
96-
file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(),
95+
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
96+
file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(),
9797
)
9898
);
9999

@@ -123,8 +123,8 @@ mod passing {
123123
{file_url_html}\n\
124124
{file_url_svg}\n\
125125
",
126-
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
127-
file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(),
126+
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
127+
file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(),
128128
)
129129
);
130130

tests/cookies/parse_cookie_file_contents.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ mod passing {
1313
fn parse_file() {
1414
let file_contents =
1515
"# Netscape HTTP Cookie File\n127.0.0.1\tFALSE\t/\tFALSE\t0\tUSER_TOKEN\tin";
16-
let result = cookies::parse_cookie_file_contents(&file_contents).unwrap();
16+
let result = cookies::parse_cookie_file_contents(file_contents).unwrap();
1717
assert_eq!(result.len(), 1);
1818
assert_eq!(result[0].domain, "127.0.0.1");
19-
assert_eq!(result[0].include_subdomains, false);
19+
assert!(!result[0].include_subdomains);
2020
assert_eq!(result[0].path, "/");
21-
assert_eq!(result[0].https_only, false);
21+
assert!(!result[0].https_only);
2222
assert_eq!(result[0].expires, 0);
2323
assert_eq!(result[0].name, "USER_TOKEN");
2424
assert_eq!(result[0].value, "in");
@@ -27,19 +27,19 @@ mod passing {
2727
#[test]
2828
fn parse_multiline_file() {
2929
let file_contents = "# HTTP Cookie File\n127.0.0.1\tFALSE\t/\tFALSE\t0\tUSER_TOKEN\tin\n127.0.0.1\tTRUE\t/\tTRUE\t9\tUSER_TOKEN\tout\n\n";
30-
let result = cookies::parse_cookie_file_contents(&file_contents).unwrap();
30+
let result = cookies::parse_cookie_file_contents(file_contents).unwrap();
3131
assert_eq!(result.len(), 2);
3232
assert_eq!(result[0].domain, "127.0.0.1");
33-
assert_eq!(result[0].include_subdomains, false);
33+
assert!(!result[0].include_subdomains);
3434
assert_eq!(result[0].path, "/");
35-
assert_eq!(result[0].https_only, false);
35+
assert!(!result[0].https_only);
3636
assert_eq!(result[0].expires, 0);
3737
assert_eq!(result[0].name, "USER_TOKEN");
3838
assert_eq!(result[0].value, "in");
3939
assert_eq!(result[1].domain, "127.0.0.1");
40-
assert_eq!(result[1].include_subdomains, true);
40+
assert!(result[1].include_subdomains);
4141
assert_eq!(result[1].path, "/");
42-
assert_eq!(result[1].https_only, true);
42+
assert!(result[1].https_only);
4343
assert_eq!(result[1].expires, 9);
4444
assert_eq!(result[1].name, "USER_TOKEN");
4545
assert_eq!(result[1].value, "out");
@@ -60,14 +60,14 @@ mod failing {
6060
#[test]
6161
fn empty() {
6262
let file_contents = "";
63-
let result = cookies::parse_cookie_file_contents(&file_contents).unwrap();
63+
let result = cookies::parse_cookie_file_contents(file_contents).unwrap();
6464
assert_eq!(result.len(), 0);
6565
}
6666

6767
#[test]
6868
fn no_header() {
6969
let file_contents = "127.0.0.1 FALSE / FALSE 0 USER_TOKEN in";
70-
match cookies::parse_cookie_file_contents(&file_contents) {
70+
match cookies::parse_cookie_file_contents(file_contents) {
7171
Ok(_result) => {
7272
assert!(false);
7373
}
@@ -81,7 +81,7 @@ mod failing {
8181
fn spaces_instead_of_tabs() {
8282
let file_contents =
8383
"# HTTP Cookie File\n127.0.0.1 FALSE / FALSE 0 USER_TOKEN in";
84-
let result = cookies::parse_cookie_file_contents(&file_contents).unwrap();
84+
let result = cookies::parse_cookie_file_contents(file_contents).unwrap();
8585
assert_eq!(result.len(), 0);
8686
}
8787
}

tests/core/options.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ mod passing {
1313
fn defaults() {
1414
let options: Options = Options::default();
1515

16-
assert_eq!(options.no_audio, false);
16+
assert!(!options.no_audio);
1717
assert_eq!(options.base_url, None);
18-
assert_eq!(options.no_css, false);
18+
assert!(!options.no_css);
1919
assert_eq!(options.encoding, None);
20-
assert_eq!(options.no_frames, false);
21-
assert_eq!(options.no_fonts, false);
22-
assert_eq!(options.no_images, false);
23-
assert_eq!(options.isolate, false);
24-
assert_eq!(options.no_js, false);
25-
assert_eq!(options.insecure, false);
26-
assert_eq!(options.no_metadata, false);
27-
assert_eq!(options.silent, false);
20+
assert!(!options.no_frames);
21+
assert!(!options.no_fonts);
22+
assert!(!options.no_images);
23+
assert!(!options.isolate);
24+
assert!(!options.no_js);
25+
assert!(!options.insecure);
26+
assert!(!options.no_metadata);
27+
assert!(!options.silent);
2828
assert_eq!(options.timeout, 0);
2929
assert_eq!(options.user_agent, None);
30-
assert_eq!(options.no_video, false);
30+
assert!(!options.no_video);
3131
}
3232
}

tests/css/embed_css.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ mod passing {
5959
height: calc(100vh - 10pt)";
6060

6161
assert_eq!(
62-
css::embed_css(cache, &client, &document_url, &STYLE, &options),
62+
css::embed_css(cache, &client, &document_url, STYLE, &options),
6363
format!(
6464
"/* border: none;*/\
6565
background-image: url(\"{empty_image}\"); \
@@ -91,7 +91,7 @@ mod passing {
9191
height: calc(100vh - 10pt)";
9292

9393
assert_eq!(
94-
css::embed_css(cache, &client, &document_url, &STYLE, &options),
94+
css::embed_css(cache, &client, &document_url, STYLE, &options),
9595
format!(
9696
"/* border: none;*/\
9797
background-image: url(\"{empty_image}\"); \
@@ -122,7 +122,7 @@ mod passing {
122122
html > body {}";
123123

124124
assert_eq!(
125-
css::embed_css(cache, &client, &document_url, &CSS, &options),
125+
css::embed_css(cache, &client, &document_url, CSS, &options),
126126
CSS
127127
);
128128
}
@@ -166,7 +166,7 @@ mod passing {
166166
";
167167

168168
assert_eq!(
169-
css::embed_css(cache, &client, &document_url, &CSS, &options),
169+
css::embed_css(cache, &client, &document_url, CSS, &options),
170170
CSS
171171
);
172172
}
@@ -188,7 +188,7 @@ mod passing {
188188
";
189189

190190
assert_eq!(
191-
css::embed_css(cache, &client, &document_url, &CSS, &options),
191+
css::embed_css(cache, &client, &document_url, CSS, &options),
192192
"\
193193
@charset \"UTF-8\";\n\
194194
\n\
@@ -218,7 +218,7 @@ mod passing {
218218
";
219219

220220
assert_eq!(
221-
css::embed_css(cache, &client, &document_url, &CSS, &options),
221+
css::embed_css(cache, &client, &document_url, CSS, &options),
222222
CSS
223223
);
224224
}
@@ -240,7 +240,7 @@ mod passing {
240240
";
241241

242242
assert_eq!(
243-
css::embed_css(cache, &client, &document_url, &CSS, &options),
243+
css::embed_css(cache, &client, &document_url, CSS, &options),
244244
CSS
245245
);
246246
}
@@ -264,7 +264,7 @@ mod passing {
264264
";
265265

266266
assert_eq!(
267-
css::embed_css(cache, &client, &document_url, &CSS, &options),
267+
css::embed_css(cache, &client, &document_url, CSS, &options),
268268
CSS
269269
);
270270
}
@@ -312,7 +312,7 @@ mod passing {
312312
";
313313

314314
assert_eq!(
315-
css::embed_css(cache, &client, &document_url, &CSS, &options),
315+
css::embed_css(cache, &client, &document_url, CSS, &options),
316316
CSS_OUT
317317
);
318318
}
@@ -337,7 +337,7 @@ mod passing {
337337
";
338338

339339
assert_eq!(
340-
css::embed_css(cache, &client, &document_url, &CSS, &options),
340+
css::embed_css(cache, &client, &document_url, CSS, &options),
341341
CSS_OUT
342342
);
343343
}
@@ -364,7 +364,7 @@ mod passing {
364364
";
365365

366366
assert_eq!(
367-
css::embed_css(cache, &client, &document_url, &CSS, &options),
367+
css::embed_css(cache, &client, &document_url, CSS, &options),
368368
CSS_OUT
369369
);
370370
}

tests/html/embed_srcset.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mod passing {
2727
cache,
2828
&client,
2929
&Url::parse("data:,").unwrap(),
30-
&srcset_value,
30+
srcset_value,
3131
&options,
3232
);
3333

@@ -52,7 +52,7 @@ mod passing {
5252
cache,
5353
&client,
5454
&Url::parse("data:,").unwrap(),
55-
&srcset_value,
55+
srcset_value,
5656
&options,
5757
);
5858

@@ -74,7 +74,7 @@ mod passing {
7474
cache,
7575
&client,
7676
&Url::parse("data:,").unwrap(),
77-
&srcset_value,
77+
srcset_value,
7878
&options,
7979
);
8080

@@ -96,7 +96,7 @@ mod passing {
9696
cache,
9797
&client,
9898
&Url::parse("data:,").unwrap(),
99-
&srcset_value,
99+
srcset_value,
100100
&options,
101101
);
102102

@@ -121,7 +121,7 @@ mod passing {
121121
cache,
122122
&client,
123123
&Url::parse("data:,").unwrap(),
124-
&srcset_value,
124+
srcset_value,
125125
&options,
126126
);
127127

@@ -146,7 +146,7 @@ mod passing {
146146
cache,
147147
&client,
148148
&Url::parse("data:,").unwrap(),
149-
&srcset_value,
149+
srcset_value,
150150
&options,
151151
);
152152

@@ -189,7 +189,7 @@ mod failing {
189189
cache,
190190
&client,
191191
&Url::parse("data:,").unwrap(),
192-
&srcset_value,
192+
srcset_value,
193193
&options,
194194
);
195195

tests/url/is_url_and_has_protocol.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,25 @@ mod failing {
8484

8585
#[test]
8686
fn url_with_no_protocol() {
87-
assert_eq!(
88-
url::is_url_and_has_protocol("//some-hostname.com/some-file.html"),
89-
false
90-
);
87+
assert!(!url::is_url_and_has_protocol(
88+
"//some-hostname.com/some-file.html"
89+
));
9190
}
9291

9392
#[test]
9493
fn relative_path() {
95-
assert_eq!(
96-
url::is_url_and_has_protocol("some-hostname.com/some-file.html"),
97-
false
98-
);
94+
assert!(!url::is_url_and_has_protocol(
95+
"some-hostname.com/some-file.html"
96+
));
9997
}
10098

10199
#[test]
102100
fn relative_to_root_path() {
103-
assert_eq!(url::is_url_and_has_protocol("/some-file.html"), false);
101+
assert!(!url::is_url_and_has_protocol("/some-file.html"));
104102
}
105103

106104
#[test]
107105
fn empty_string() {
108-
assert_eq!(url::is_url_and_has_protocol(""), false);
106+
assert!(!url::is_url_and_has_protocol(""));
109107
}
110108
}

0 commit comments

Comments
 (0)