1
0
Fork 0

Use impl trait

This commit is contained in:
Malte Brandy 2018-06-09 14:23:40 +02:00
parent a64d498d5b
commit 479f77473c
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
2 changed files with 12 additions and 12 deletions

View file

@ -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 {

View file

@ -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<()> {