Use impl trait
This commit is contained in:
parent
a64d498d5b
commit
479f77473c
2 changed files with 12 additions and 12 deletions
|
@ -20,16 +20,19 @@ pub enum Timer {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait TaskRefresher {
|
pub trait TaskRefresher {
|
||||||
fn reactivate<T>(&mut self, tasks: T, recurrence: Timer) -> Result<()>
|
fn reactivate(
|
||||||
where
|
&mut self,
|
||||||
T: IntoIterator<Item = Task>;
|
tasks: impl IntoIterator<Item = Task>,
|
||||||
|
recurrence: Timer,
|
||||||
|
) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TaskRefresher for TaskCache {
|
impl TaskRefresher for TaskCache {
|
||||||
fn reactivate<T>(&mut self, tasks: T, recurrence: Timer) -> Result<()>
|
fn reactivate(
|
||||||
where
|
&mut self,
|
||||||
T: IntoIterator<Item = Task>,
|
tasks: impl IntoIterator<Item = Task>,
|
||||||
{
|
recurrence: Timer,
|
||||||
|
) -> Result<()> {
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
let now_moment = TT::Moment(Local::now().naive_local());
|
let now_moment = TT::Moment(Local::now().naive_local());
|
||||||
let recent = match recurrence {
|
let recent = match recurrence {
|
||||||
|
|
|
@ -18,11 +18,8 @@ fn simple_task(name: &str) -> Task {
|
||||||
task
|
task
|
||||||
}
|
}
|
||||||
|
|
||||||
fn simple_tasks<'a, T>(names: T) -> Vec<Task>
|
fn simple_tasks<'a>(names: impl IntoIterator<Item = &'a str>) -> impl Iterator<Item = Task> {
|
||||||
where
|
names.into_iter().map(simple_task)
|
||||||
T: IntoIterator<Item = &'a str>,
|
|
||||||
{
|
|
||||||
names.into_iter().map(simple_task).collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_tasks(cache: &mut TaskCache) -> Result<()> {
|
pub fn update_tasks(cache: &mut TaskCache) -> Result<()> {
|
||||||
|
|
Loading…
Reference in a new issue