aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 {