chore: apply clippy's suggestions
parent
10140d879c
commit
180768b858
|
@ -57,7 +57,7 @@ impl Resource {
|
||||||
duration = duration + Duration::minutes(hour.granularity.into());
|
duration = duration + Duration::minutes(hour.granularity.into());
|
||||||
} else {
|
} else {
|
||||||
out.push((start_hour, duration));
|
out.push((start_hour, duration));
|
||||||
start_hour = &hour;
|
start_hour = hour;
|
||||||
duration = Duration::minutes(hour.granularity.into());
|
duration = Duration::minutes(hour.granularity.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,7 @@ impl str::FromStr for HumanNaiveDate {
|
||||||
type Err = chrono::format::ParseError;
|
type Err = chrono::format::ParseError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> chrono::format::ParseResult<Self> {
|
fn from_str(s: &str) -> chrono::format::ParseResult<Self> {
|
||||||
if let Some(days_to_add) = DAY_TERMS
|
if let Some(days_to_add) = DAY_TERMS.iter().position(|term| s.to_lowercase() == *term) {
|
||||||
.iter()
|
|
||||||
.position(|term| s.to_lowercase() == term.to_string())
|
|
||||||
{
|
|
||||||
let now = chrono::Local::now().naive_local().date();
|
let now = chrono::Local::now().naive_local().date();
|
||||||
|
|
||||||
// days_to_add will never be greater than 2
|
// days_to_add will never be greater than 2
|
||||||
|
@ -44,14 +41,14 @@ impl str::FromStr for HumanNaiveDate {
|
||||||
now + chrono::Duration::days(days_to_add.into()),
|
now + chrono::Duration::days(days_to_add.into()),
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
chrono::NaiveDate::from_str(s).map(|d| HumanNaiveDate(d))
|
chrono::NaiveDate::from_str(s).map(HumanNaiveDate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<chrono::NaiveDate> for HumanNaiveDate {
|
impl From<HumanNaiveDate> for chrono::NaiveDate {
|
||||||
fn into(self) -> chrono::NaiveDate {
|
fn from(val: HumanNaiveDate) -> chrono::NaiveDate {
|
||||||
self.0
|
val.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue