aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2020-05-13 16:33:27 +0200
committerDaniel <kingdread@gmx.de>2020-05-13 16:33:27 +0200
commitb6a13c465983993ac581051bb24a13d4296731a1 (patch)
tree2d3898ca6d2302910948964224496d79a842c2ff /src
parentfb2a6088dcc7b57a2c1ac93ec6a8fbcc52584734 (diff)
downloadraidgrep-b6a13c465983993ac581051bb24a13d4296731a1.tar.gz
raidgrep-b6a13c465983993ac581051bb24a13d4296731a1.tar.bz2
raidgrep-b6a13c465983993ac581051bb24a13d4296731a1.zip
fix Aggregator::finish for trait objects
Diffstat (limited to 'src')
-rw-r--r--src/main.rs5
-rw-r--r--src/output/aggregators.rs9
2 files changed, 8 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index ad996ea..cb914d3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -384,7 +384,7 @@ fn build_filter(expr_string: &str) -> Result<Box<dyn LogFilter>> {
fn grep(opt: &Opt, filter: &dyn LogFilter) -> Result<()> {
let pipeline = output::build_pipeline(opt);
let pipeline_ref = &pipeline;
- rayon::scope(|s| {
+ let result: Result<()> = rayon::scope(|s| {
let walker = WalkDir::new(&opt.path);
for entry in walker {
let entry = entry?;
@@ -406,7 +406,8 @@ fn grep(opt: &Opt, filter: &dyn LogFilter) -> Result<()> {
});
}
Ok(())
- }) as Result<()>;
+ });
+ result?;
pipeline.finish();
Ok(())
}
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 {