clippy: Fix a bunch of warnings in script (#32680)

This is just a portion of the errors that are remaining to be fixed.
This commit is contained in:
Martin Robinson 2024-07-04 13:40:23 +02:00 committed by GitHub
parent 93fdb8263d
commit 26624a109f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 150 additions and 113 deletions

View file

@ -73,7 +73,7 @@ pub fn build_html_directory_listing(
if let Ok(mut path_segments) = parent_url.path_segments_mut() {
path_segments.pop();
}
parent_url_string = parent_url.as_str().to_owned();
parent_url.as_str().clone_into(&mut parent_url_string);
}
page_html.push_str(&read_string(Resource::DirectoryListingHTML));
@ -126,7 +126,7 @@ fn write_directory_entry(entry: DirEntry, metadata: Metadata, url: &Url, output:
let file_size = metadata_to_file_size_string(&metadata);
let last_modified = metadata
.modified()
.map(|time| DateTime::<Local>::from(time))
.map(DateTime::<Local>::from)
.map(|time| time.format("%F %r").to_string())
.unwrap_or_default();
@ -154,5 +154,5 @@ pub fn metadata_to_file_size_string(metadata: &Metadata) -> String {
_ => "GB",
};
return format!("{:.2} {prefix}", float_size);
format!("{:.2} {prefix}", float_size)
}

View file

@ -565,14 +565,14 @@ impl MIMEChecker for GroupedClassifier {
}
enum Match {
None,
Start,
DidNotMatch,
StartAndEnd,
}
impl Match {
fn chain<F: FnOnce() -> Match>(self, f: F) -> Match {
if let Match::DidNotMatch = self {
if let Match::None = self {
return f();
}
self
@ -584,7 +584,7 @@ where
T: Iterator<Item = &'a u8> + Clone,
{
if !matcher.matches(start) {
Match::DidNotMatch
Match::None
} else if end.len() == 1 {
if matcher.any(|&x| x == end[0]) {
Match::StartAndEnd
@ -630,7 +630,7 @@ impl FeedsClassifier {
.chain(|| eats_until(&mut matcher, b"!", b">"))
{
Match::StartAndEnd => continue,
Match::DidNotMatch => {},
Match::None => {},
Match::Start => return None,
}
@ -658,7 +658,7 @@ impl FeedsClassifier {
)
}) {
Match::StartAndEnd => return Some("application/rss+xml".parse().unwrap()),
Match::DidNotMatch => {},
Match::None => {},
Match::Start => return None,
}
}