diff --git a/src/main.rs b/src/main.rs index 2b092344..e4bff8db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,7 +46,7 @@ impl Output { } } -const ASCII: &'static str = " \ +const ASCII: &str = " \ _____ ______________ __________ ___________________ ___ | \\ / \\ | | | | | | | \\_/ __ \\_| __ | | ___ ___ |__| | @@ -57,7 +57,7 @@ const ASCII: &'static str = " \ "; const CACHE_ASSET_FILE_SIZE_THRESHOLD: usize = 1024 * 50; // Minimum file size for on-disk caching (in bytes) const DEFAULT_NETWORK_TIMEOUT: u64 = 120; -const DEFAULT_USER_AGENT: &'static str = +const DEFAULT_USER_AGENT: &str = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0"; const ENV_VAR_NO_COLOR: &str = "NO_COLOR"; const ENV_VAR_TERM: &str = "TERM"; @@ -135,7 +135,7 @@ fn main() { options.encoding = Some(encoding.to_string()); } if let Some(domains) = app.get_many::("domains") { - let list_of_domains: Vec = domains.map(|v| v.clone()).collect::>(); + let list_of_domains: Vec = domains.cloned().collect::>(); options.domains = Some(list_of_domains); } options.ignore_errors = app.is_present("ignore-errors"); diff --git a/tests/cli/basic.rs b/tests/cli/basic.rs index e5d38a05..96cff8b6 100644 --- a/tests/cli/basic.rs +++ b/tests/cli/basic.rs @@ -95,8 +95,8 @@ mod passing { {file_url_css}\n\ {file_url_css}\n\ ", - file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(), - file_url_css = Url::from_file_path(fs::canonicalize(&path_css).unwrap()).unwrap(), + file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(), + file_url_css = Url::from_file_path(fs::canonicalize(path_css).unwrap()).unwrap(), ) ); diff --git a/tests/cli/local_files.rs b/tests/cli/local_files.rs index 20871c78..a4ff2c4d 100644 --- a/tests/cli/local_files.rs +++ b/tests/cli/local_files.rs @@ -88,7 +88,7 @@ mod passing { String::from_utf8_lossy(&out.stderr), format!( "{file_url_html}\n", - file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(), + file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(), ) ); @@ -188,8 +188,8 @@ mod passing { {file_url_html}\n\ {file_url_svg}\n\ ", - file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(), - file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(), + file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(), + file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(), ) ); diff --git a/tests/cli/noscript.rs b/tests/cli/noscript.rs index 9dd3b0d0..902895cb 100644 --- a/tests/cli/noscript.rs +++ b/tests/cli/noscript.rs @@ -30,8 +30,8 @@ mod passing { {file_url_html}\n\ {file_url_svg}\n\ ", - file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(), - file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(), + file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(), + file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(), ) ); @@ -61,8 +61,8 @@ mod passing { {file_url_html}\n\ {file_url_svg}\n\ ", - file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(), - file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(), + file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(), + file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(), ) ); @@ -92,8 +92,8 @@ mod passing { {file_url_html}\n\ {file_url_svg}\n\ ", - file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(), - file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(), + file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(), + file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(), ) ); @@ -123,8 +123,8 @@ mod passing { {file_url_html}\n\ {file_url_svg}\n\ ", - file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(), - file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(), + file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(), + file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(), ) ); diff --git a/tests/cookies/parse_cookie_file_contents.rs b/tests/cookies/parse_cookie_file_contents.rs index 28857ded..e7067d37 100644 --- a/tests/cookies/parse_cookie_file_contents.rs +++ b/tests/cookies/parse_cookie_file_contents.rs @@ -13,12 +13,12 @@ mod passing { fn parse_file() { let file_contents = "# Netscape HTTP Cookie File\n127.0.0.1\tFALSE\t/\tFALSE\t0\tUSER_TOKEN\tin"; - let result = cookies::parse_cookie_file_contents(&file_contents).unwrap(); + let result = cookies::parse_cookie_file_contents(file_contents).unwrap(); assert_eq!(result.len(), 1); assert_eq!(result[0].domain, "127.0.0.1"); - assert_eq!(result[0].include_subdomains, false); + assert!(!result[0].include_subdomains); assert_eq!(result[0].path, "/"); - assert_eq!(result[0].https_only, false); + assert!(!result[0].https_only); assert_eq!(result[0].expires, 0); assert_eq!(result[0].name, "USER_TOKEN"); assert_eq!(result[0].value, "in"); @@ -27,19 +27,19 @@ mod passing { #[test] fn parse_multiline_file() { 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"; - let result = cookies::parse_cookie_file_contents(&file_contents).unwrap(); + let result = cookies::parse_cookie_file_contents(file_contents).unwrap(); assert_eq!(result.len(), 2); assert_eq!(result[0].domain, "127.0.0.1"); - assert_eq!(result[0].include_subdomains, false); + assert!(!result[0].include_subdomains); assert_eq!(result[0].path, "/"); - assert_eq!(result[0].https_only, false); + assert!(!result[0].https_only); assert_eq!(result[0].expires, 0); assert_eq!(result[0].name, "USER_TOKEN"); assert_eq!(result[0].value, "in"); assert_eq!(result[1].domain, "127.0.0.1"); - assert_eq!(result[1].include_subdomains, true); + assert!(result[1].include_subdomains); assert_eq!(result[1].path, "/"); - assert_eq!(result[1].https_only, true); + assert!(result[1].https_only); assert_eq!(result[1].expires, 9); assert_eq!(result[1].name, "USER_TOKEN"); assert_eq!(result[1].value, "out"); @@ -60,14 +60,14 @@ mod failing { #[test] fn empty() { let file_contents = ""; - let result = cookies::parse_cookie_file_contents(&file_contents).unwrap(); + let result = cookies::parse_cookie_file_contents(file_contents).unwrap(); assert_eq!(result.len(), 0); } #[test] fn no_header() { let file_contents = "127.0.0.1 FALSE / FALSE 0 USER_TOKEN in"; - match cookies::parse_cookie_file_contents(&file_contents) { + match cookies::parse_cookie_file_contents(file_contents) { Ok(_result) => { assert!(false); } @@ -81,7 +81,7 @@ mod failing { fn spaces_instead_of_tabs() { let file_contents = "# HTTP Cookie File\n127.0.0.1 FALSE / FALSE 0 USER_TOKEN in"; - let result = cookies::parse_cookie_file_contents(&file_contents).unwrap(); + let result = cookies::parse_cookie_file_contents(file_contents).unwrap(); assert_eq!(result.len(), 0); } } diff --git a/tests/core/options.rs b/tests/core/options.rs index 5366106c..e81893e7 100644 --- a/tests/core/options.rs +++ b/tests/core/options.rs @@ -13,20 +13,20 @@ mod passing { fn defaults() { let options: Options = Options::default(); - assert_eq!(options.no_audio, false); + assert!(!options.no_audio); assert_eq!(options.base_url, None); - assert_eq!(options.no_css, false); + assert!(!options.no_css); assert_eq!(options.encoding, None); - assert_eq!(options.no_frames, false); - assert_eq!(options.no_fonts, false); - assert_eq!(options.no_images, false); - assert_eq!(options.isolate, false); - assert_eq!(options.no_js, false); - assert_eq!(options.insecure, false); - assert_eq!(options.no_metadata, false); - assert_eq!(options.silent, false); + assert!(!options.no_frames); + assert!(!options.no_fonts); + assert!(!options.no_images); + assert!(!options.isolate); + assert!(!options.no_js); + assert!(!options.insecure); + assert!(!options.no_metadata); + assert!(!options.silent); assert_eq!(options.timeout, 0); assert_eq!(options.user_agent, None); - assert_eq!(options.no_video, false); + assert!(!options.no_video); } } diff --git a/tests/css/embed_css.rs b/tests/css/embed_css.rs index f4a028c8..b15fd894 100644 --- a/tests/css/embed_css.rs +++ b/tests/css/embed_css.rs @@ -59,7 +59,7 @@ mod passing { height: calc(100vh - 10pt)"; assert_eq!( - css::embed_css(cache, &client, &document_url, &STYLE, &options), + css::embed_css(cache, &client, &document_url, STYLE, &options), format!( "/* border: none;*/\ background-image: url(\"{empty_image}\"); \ @@ -91,7 +91,7 @@ mod passing { height: calc(100vh - 10pt)"; assert_eq!( - css::embed_css(cache, &client, &document_url, &STYLE, &options), + css::embed_css(cache, &client, &document_url, STYLE, &options), format!( "/* border: none;*/\ background-image: url(\"{empty_image}\"); \ @@ -122,7 +122,7 @@ mod passing { html > body {}"; assert_eq!( - css::embed_css(cache, &client, &document_url, &CSS, &options), + css::embed_css(cache, &client, &document_url, CSS, &options), CSS ); } @@ -166,7 +166,7 @@ mod passing { "; assert_eq!( - css::embed_css(cache, &client, &document_url, &CSS, &options), + css::embed_css(cache, &client, &document_url, CSS, &options), CSS ); } @@ -188,7 +188,7 @@ mod passing { "; assert_eq!( - css::embed_css(cache, &client, &document_url, &CSS, &options), + css::embed_css(cache, &client, &document_url, CSS, &options), "\ @charset \"UTF-8\";\n\ \n\ @@ -218,7 +218,7 @@ mod passing { "; assert_eq!( - css::embed_css(cache, &client, &document_url, &CSS, &options), + css::embed_css(cache, &client, &document_url, CSS, &options), CSS ); } @@ -240,7 +240,7 @@ mod passing { "; assert_eq!( - css::embed_css(cache, &client, &document_url, &CSS, &options), + css::embed_css(cache, &client, &document_url, CSS, &options), CSS ); } @@ -264,7 +264,7 @@ mod passing { "; assert_eq!( - css::embed_css(cache, &client, &document_url, &CSS, &options), + css::embed_css(cache, &client, &document_url, CSS, &options), CSS ); } @@ -312,7 +312,7 @@ mod passing { "; assert_eq!( - css::embed_css(cache, &client, &document_url, &CSS, &options), + css::embed_css(cache, &client, &document_url, CSS, &options), CSS_OUT ); } @@ -337,7 +337,7 @@ mod passing { "; assert_eq!( - css::embed_css(cache, &client, &document_url, &CSS, &options), + css::embed_css(cache, &client, &document_url, CSS, &options), CSS_OUT ); } @@ -364,7 +364,7 @@ mod passing { "; assert_eq!( - css::embed_css(cache, &client, &document_url, &CSS, &options), + css::embed_css(cache, &client, &document_url, CSS, &options), CSS_OUT ); } diff --git a/tests/html/embed_srcset.rs b/tests/html/embed_srcset.rs index 91bd0140..8f5b5bb8 100644 --- a/tests/html/embed_srcset.rs +++ b/tests/html/embed_srcset.rs @@ -27,7 +27,7 @@ mod passing { cache, &client, &Url::parse("data:,").unwrap(), - &srcset_value, + srcset_value, &options, ); @@ -52,7 +52,7 @@ mod passing { cache, &client, &Url::parse("data:,").unwrap(), - &srcset_value, + srcset_value, &options, ); @@ -74,7 +74,7 @@ mod passing { cache, &client, &Url::parse("data:,").unwrap(), - &srcset_value, + srcset_value, &options, ); @@ -96,7 +96,7 @@ mod passing { cache, &client, &Url::parse("data:,").unwrap(), - &srcset_value, + srcset_value, &options, ); @@ -121,7 +121,7 @@ mod passing { cache, &client, &Url::parse("data:,").unwrap(), - &srcset_value, + srcset_value, &options, ); @@ -146,7 +146,7 @@ mod passing { cache, &client, &Url::parse("data:,").unwrap(), - &srcset_value, + srcset_value, &options, ); @@ -189,7 +189,7 @@ mod failing { cache, &client, &Url::parse("data:,").unwrap(), - &srcset_value, + srcset_value, &options, ); diff --git a/tests/url/is_url_and_has_protocol.rs b/tests/url/is_url_and_has_protocol.rs index 38a1d8fb..0a3cc0d8 100644 --- a/tests/url/is_url_and_has_protocol.rs +++ b/tests/url/is_url_and_has_protocol.rs @@ -84,27 +84,25 @@ mod failing { #[test] fn url_with_no_protocol() { - assert_eq!( - url::is_url_and_has_protocol("//some-hostname.com/some-file.html"), - false - ); + assert!(!url::is_url_and_has_protocol( + "//some-hostname.com/some-file.html" + )); } #[test] fn relative_path() { - assert_eq!( - url::is_url_and_has_protocol("some-hostname.com/some-file.html"), - false - ); + assert!(!url::is_url_and_has_protocol( + "some-hostname.com/some-file.html" + )); } #[test] fn relative_to_root_path() { - assert_eq!(url::is_url_and_has_protocol("/some-file.html"), false); + assert!(!url::is_url_and_has_protocol("/some-file.html")); } #[test] fn empty_string() { - assert_eq!(url::is_url_and_has_protocol(""), false); + assert!(!url::is_url_and_has_protocol("")); } }