Adapt imag-habit impl for HabitInstance::get_comment()
The implementation of `HabitInstance::get_comment()` was changed and therefore its semantics were changed. This patch adapts the call to the function for the new signature and implications. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
191b535479
commit
62d6b54542
1 changed files with 13 additions and 6 deletions
|
@ -473,12 +473,12 @@ fn show(rt: &Runtime) {
|
||||||
.map(String::from)
|
.map(String::from)
|
||||||
.unwrap(); // safe by clap
|
.unwrap(); // safe by clap
|
||||||
|
|
||||||
fn instance_lister_fn(i: &FileLockEntry) -> Vec<String> {
|
fn instance_lister_fn(rt: &Runtime, i: &FileLockEntry) -> Vec<String> {
|
||||||
use libimagutil::date::date_to_string;
|
use libimagutil::date::date_to_string;
|
||||||
use libimaghabit::instance::HabitInstance;
|
use libimaghabit::instance::HabitInstance;
|
||||||
|
|
||||||
let date = date_to_string(&i.get_date().map_err_trace_exit_unwrap());
|
let date = date_to_string(&i.get_date().map_err_trace_exit_unwrap());
|
||||||
let comm = i.get_comment().map_err_trace_exit_unwrap();
|
let comm = i.get_comment(rt.store()).map_err_trace_exit_unwrap();
|
||||||
|
|
||||||
vec![date, comm]
|
vec![date, comm]
|
||||||
}
|
}
|
||||||
|
@ -516,7 +516,7 @@ fn show(rt: &Runtime) {
|
||||||
.unwrap_or_exit();
|
.unwrap_or_exit();
|
||||||
|
|
||||||
let mut empty = true;
|
let mut empty = true;
|
||||||
let _ = habit
|
let iter = habit
|
||||||
.linked_instances()
|
.linked_instances()
|
||||||
.map_err_trace_exit_unwrap()
|
.map_err_trace_exit_unwrap()
|
||||||
.trace_unwrap_exit()
|
.trace_unwrap_exit()
|
||||||
|
@ -524,10 +524,17 @@ fn show(rt: &Runtime) {
|
||||||
debug!("Getting: {:?}", instance_id);
|
debug!("Getting: {:?}", instance_id);
|
||||||
rt.store().get(instance_id).map_err_trace_exit_unwrap()
|
rt.store().get(instance_id).map_err_trace_exit_unwrap()
|
||||||
})
|
})
|
||||||
.enumerate()
|
.enumerate();
|
||||||
.for_each(|(i, e)| {
|
|
||||||
|
// We need to drop here because we iterate over instances and in the
|
||||||
|
// instance_lister_fn() we call instance.get_comment(), which internally tries to
|
||||||
|
// Store::get() the template object.
|
||||||
|
// This would fail because the template is already borrowed.
|
||||||
|
drop(habit);
|
||||||
|
|
||||||
|
iter.for_each(|(i, e)| {
|
||||||
let mut v = vec![format!("{}", i)];
|
let mut v = vec![format!("{}", i)];
|
||||||
let mut instances = instance_lister_fn(&e);
|
let mut instances = instance_lister_fn(&rt, &e);
|
||||||
|
|
||||||
{
|
{
|
||||||
let _ = rt.report_touched(e.get_location()).unwrap_or_exit();
|
let _ = rt.report_touched(e.get_location()).unwrap_or_exit();
|
||||||
|
|
Loading…
Reference in a new issue