From 2cd511c0c19267a93348e5a20823307e96781ad3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 4 Jul 2016 20:04:38 +0200 Subject: [PATCH 1/2] Make CoreLister generic --- libimagentrylist/src/listers/core.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libimagentrylist/src/listers/core.rs b/libimagentrylist/src/listers/core.rs index 50913258..f2f83eea 100644 --- a/libimagentrylist/src/listers/core.rs +++ b/libimagentrylist/src/listers/core.rs @@ -7,21 +7,21 @@ use result::Result; use libimagstore::store::FileLockEntry; use libimagstore::store::Entry; -pub struct CoreLister<'a> { - lister: &'a Fn(&Entry) -> String, +pub struct CoreLister String> { + lister: Box, } -impl<'a> CoreLister<'a> { +impl String> CoreLister { - pub fn new(lister: &'a Fn(&Entry) -> String) -> CoreLister<'a> { + pub fn new(lister: T) -> CoreLister { CoreLister { - lister: lister, + lister: Box::new(lister), } } } -impl<'a> Lister for CoreLister<'a> { +impl String> Lister for CoreLister { fn list<'b, I: Iterator>>(&self, entries: I) -> Result<()> { use error::ListError as LE; From 66cdc192c24fe0cbbd26d0c61034b35d84e84f70 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 4 Jul 2016 20:13:45 +0200 Subject: [PATCH 2/2] Annotate that we have a closure which takes &Entry here --- imag-diary/src/list.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imag-diary/src/list.rs b/imag-diary/src/list.rs index 413213c0..9c0cc3c5 100644 --- a/imag-diary/src/list.rs +++ b/imag-diary/src/list.rs @@ -7,6 +7,7 @@ use libimagdiary::error::DiaryErrorKind as DEK; use libimagentrylist::listers::core::CoreLister; use libimagentrylist::lister::Lister; use libimagrt::runtime::Runtime; +use libimagstore::store::Entry; use libimagstore::storeid::StoreId; use libimagerror::trace::trace_error; @@ -41,7 +42,7 @@ pub fn list(rt: &Runtime) { let base = rt.store().path(); - CoreLister::new(&move |e| location_to_listing_string(e.get_location(), base)) + CoreLister::new(&move |e: &Entry| location_to_listing_string(e.get_location(), base)) .list(es) // TODO: Do not ignore non-ok()s .map_err(|e| DE::new(DEK::IOError, Some(Box::new(e)))) })