From b6a13c465983993ac581051bb24a13d4296731a1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 May 2020 16:33:27 +0200 Subject: fix Aggregator::finish for trait objects --- src/output/aggregators.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/output/aggregators.rs') 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, 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, _: &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, 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 { -- cgit v1.2.3