mirror of
https://github.com/0x5eal/chrono-lc.git
synced 2024-12-13 21:40:42 +00:00
chore: please the clippy overlords - 2
This commit is contained in:
parent
50168ae609
commit
33bbea3e07
1 changed files with 9 additions and 9 deletions
18
src/lib.rs
18
src/lib.rs
|
@ -28,11 +28,11 @@
|
||||||
//! # use chrono_lc::LocaleDate;
|
//! # use chrono_lc::LocaleDate;
|
||||||
//!
|
//!
|
||||||
//! let dt = FixedOffset::east_opt(34200)
|
//! let dt = FixedOffset::east_opt(34200)
|
||||||
//! .unwrap()
|
//! .unwrap()
|
||||||
//! .with_ymd_and_hms(2001, 7, 8, 0, 34, 59)
|
//! .with_ymd_and_hms(2001, 7, 8, 0, 34, 59)
|
||||||
//! .unwrap()
|
//! .unwrap()
|
||||||
//! .with_nanosecond(1_026_490_708)
|
//! .with_nanosecond(1_026_490_708)
|
||||||
//! .unwrap();
|
//! .unwrap();
|
||||||
//!
|
//!
|
||||||
//! println!("{}", dt.formatl("%c", "fr"));
|
//! println!("{}", dt.formatl("%c", "fr"));
|
||||||
//! ```
|
//! ```
|
||||||
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue