chore: please the clippy overlords - 2

This commit is contained in:
Erica Marigold 2023-09-13 18:32:24 +05:30 committed by GitHub
parent 50168ae609
commit 33bbea3e07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -158,7 +158,7 @@ pub fn format_l10n<'a, I>(
where where
I: Iterator<Item = Item<'a>>, I: Iterator<Item = Item<'a>>,
{ {
let locale = locale.to_lowercase().replace("_", "-"); let locale = locale.to_lowercase().replace('_', "-");
for item in items { for item in items {
match item { match item {
Item::Literal(s) | Item::Space(s) => write!(w, "{}", s)?, Item::Literal(s) | Item::Space(s) => write!(w, "{}", s)?,
@ -203,7 +203,7 @@ where
}; };
if let Some(v) = v { if let Some(v) = v {
if (spec == Year || spec == IsoYear) && !(0 <= v && v < 10_000) { if (spec == Year || spec == IsoYear) && !(0..10_000).contains(&v) {
// non-four-digit years require an explicit sign as per ISO 8601 // non-four-digit years require an explicit sign as per ISO 8601
match pad { match pad {
Pad::None => write!(w, "{:+}", v)?, Pad::None => write!(w, "{:+}", v)?,
@ -273,7 +273,7 @@ where
write!(w, ".{:09}", nano) write!(w, ".{:09}", nano)
}), }),
Internal(_) => panic!("Internal is not supported"), Internal(_) => panic!("Internal is not supported"),
TimezoneName => off.map(|&(ref name, _)| write!(w, "{}", *name)), TimezoneName => off.map(|(name, _)| write!(w, "{}", *name)),
TimezoneOffsetColon => off.map(|&(_, off)| write_local_minus_utc(w, off, false, true)), TimezoneOffsetColon => off.map(|&(_, off)| write_local_minus_utc(w, off, false, true)),
TimezoneOffsetColonZ => off.map(|&(_, off)| write_local_minus_utc(w, off, true, true)), TimezoneOffsetColonZ => off.map(|&(_, off)| write_local_minus_utc(w, off, true, true)),
TimezoneOffsetDoubleColon => off.map(|&(_, off)| write_local_minus_utc(w, off, false, true)), TimezoneOffsetDoubleColon => off.map(|&(_, off)| write_local_minus_utc(w, off, false, true)),
@ -356,7 +356,7 @@ fn find_key(key: usize, data: &'static HashMap<String, Vec<&'static str>>, local
locale locale
.split('-') .split('-')
.collect::<Vec<&str>>() .collect::<Vec<&str>>()
.get(0) .first()
.cloned() .cloned()
.and_then(|locale| data.get(locale).and_then(|res| res.get(key))) .and_then(|locale| data.get(locale).and_then(|res| res.get(key)))
} else { } else {