diff options
author | Daniel <kingdread@gmx.de> | 2020-05-13 16:33:27 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2020-05-13 16:33:27 +0200 |
commit | b6a13c465983993ac581051bb24a13d4296731a1 (patch) | |
tree | 2d3898ca6d2302910948964224496d79a842c2ff /src/output | |
parent | fb2a6088dcc7b57a2c1ac93ec6a8fbcc52584734 (diff) | |
download | raidgrep-b6a13c465983993ac581051bb24a13d4296731a1.tar.gz raidgrep-b6a13c465983993ac581051bb24a13d4296731a1.tar.bz2 raidgrep-b6a13c465983993ac581051bb24a13d4296731a1.zip |
fix Aggregator::finish for trait objects
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/aggregators.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/output/aggregators.rs b/src/output/aggregators.rs index 4fa2558..24adbf8 100644 --- a/src/output/aggregators.rs +++ b/src/output/aggregators.rs @@ -15,7 +15,8 @@ use std::{ pub trait Aggregator: Sync { fn push_item(&self, item: LogResult, format: &dyn Format, stream: &mut dyn Write); - fn finish(self, format: &dyn Format, stream: &mut dyn Write); + // When the `unsized_locals` feature is stable, we could rewrite this to finish(self, ...). + fn finish(self: Box<Self>, format: &dyn Format, stream: &mut dyn Write); } /// An aggregator that just pushes through each item to the output stream without any sorting or @@ -29,7 +30,7 @@ impl Aggregator for WriteThrough { stream.flush().unwrap(); } - fn finish(self, _: &dyn Format, _: &mut dyn Write) {} + fn finish(self: Box<Self>, _: &dyn Format, _: &mut dyn Write) {} } /// An aggregator that keeps all found logs in memory and sorts them before outputting them. @@ -53,8 +54,8 @@ impl Aggregator for SortedOutput { self.items.lock().unwrap().push(item) } - fn finish(self, format: &dyn Format, stream: &mut dyn Write) { - let SortedOutput { sorting, items } = self; + fn finish(self: Box<Self>, format: &dyn Format, stream: &mut dyn Write) { + let SortedOutput { sorting, items } = *self; let mut items = items.into_inner().unwrap(); items.sort_unstable_by(|a, b| sorting.cmp(a, b)); for item in items { |