From c04bf490e989b17c2427d94f1d05cf57ebc1d846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 31 Jul 2021 21:27:48 +0200 Subject: working sort_by_func --- cli/src/main.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'cli') diff --git a/cli/src/main.rs b/cli/src/main.rs index 677ba1e..7e1b80f 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -154,17 +154,17 @@ fn main() { } } -fn sort_by_func(sort: &SortTarget) -> Box std::cmp::Ordering> { +fn sort_by_func(sort: &SortTarget) -> Box std::cmp::Ordering> { match sort { - SortTarget::Amount => |t1, t2| t1.amount.cmp(&t2.amount), - SortTarget::Date => |t1, t2| t1.date.cmp(&t2.date), + SortTarget::Amount => Box::new(|t1: &&Transaction, t2: &&Transaction| t1.amount.cmp(&t2.amount)), + SortTarget::Date => Box::new(|t1: &&Transaction, t2: &&Transaction| t1.date.cmp(&t2.date)), } } -fn inner_sort_by( - v: &mut [Transaction], - mut outer_cmp: Box std::cmp::Ordering>, - mut inner_cmp: Box std::cmp::Ordering>, +fn inner_sort_by( + v: &mut [T], + mut outer_cmp: Box std::cmp::Ordering>, + mut inner_cmp: Box std::cmp::Ordering>, ) { // Early out if v.len() < 2 { -- cgit v1.2.1