Skip to content

Commit

Permalink
Rust version bump, address new clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
xnuter committed Nov 11, 2022
1 parent 421e6b4 commit 73d3188
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --features full -- -D warnings
args: --features full --tests -- -D warnings

rustfmt:
name: Format
Expand Down
12 changes: 2 additions & 10 deletions src/bench_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,9 @@ impl BenchRun {

/// Each async operation must be time-bound.
pub async fn timed_operation<T: Future>(&self, f: T) -> Result<<T as Future>::Output, ()> {
if let Some(timeout_value) = self.timeout {
let result = timeout(timeout_value, f).await;
let Some(timeout_value) = self.timeout else { return Ok(f.await); };

if let Ok(r) = result {
Ok(r)
} else {
Err(())
}
} else {
Ok(f.await)
}
timeout(timeout_value, f).await.map_err(|_| ())
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ impl BenchmarkConfig {
}

fn read_file_as_vec(filename: &str) -> Vec<u8> {
let mut f = File::open(&filename).expect("File not found");
let metadata = fs::metadata(&filename).expect("Cannot get metadata");
let mut f = File::open(filename).expect("File not found");
let metadata = fs::metadata(filename).expect("Cannot get metadata");
let mut buffer = vec![0; metadata.len() as usize];
f.read_exact(&mut buffer)
.map_err(|e| panic!("Error reading file {}: {}", filename, e))
Expand Down
18 changes: 10 additions & 8 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,11 @@ impl DefaultConsoleReporter {
}

fn sorted_operations(metrics: &BenchRunMetrics) -> Vec<String> {
let sorted_operation_name: Vec<String> =
metrics.by_operation.keys().map(|s| s.to_owned()).collect();
sorted_operation_name
metrics
.by_operation
.keys()
.map(String::to_owned)
.collect::<Vec<_>>()
}

fn build_report(&self, metrics: &BenchRunMetrics) -> BenchRunReport {
Expand Down Expand Up @@ -472,7 +474,7 @@ mod tests {
}

let report = DefaultConsoleReporter::new(None).build_report(&metrics);
let mut items = report.combined.latency_summary.to_owned().into_iter();
let mut items = report.combined.latency_summary.iter().cloned();

assert_eq!(Some(("Min".to_string(), 0)), items.next());
assert_eq!(Some(("p50".to_string(), 500)), items.next());
Expand All @@ -492,8 +494,8 @@ mod tests {
.get("OperationA")
.unwrap()
.latency_summary
.to_owned()
.into_iter();
.iter()
.cloned();
assert_eq!(Some(("Min".to_string(), 0)), items.next());
assert_eq!(Some(("p50".to_string(), 500)), items.next());
assert_eq!(Some(("p90".to_string(), 900)), items.next());
Expand All @@ -510,8 +512,8 @@ mod tests {
.get("OperationB")
.unwrap()
.latency_summary
.to_owned()
.into_iter();
.iter()
.cloned();
assert_eq!(Some(("Min".to_string(), 1)), items.next());
assert_eq!(Some(("p50".to_string(), 501)), items.next());
assert_eq!(Some(("p90".to_string(), 901)), items.next());
Expand Down
6 changes: 3 additions & 3 deletions src/prometheus_reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ mod test {
(false, "500".to_string())
};
total_bytes += i;
successful_requests += if success { 1 } else { 0 };
successful_requests += i32::from(success);
total_requests += 1;

metrics.report_request(
Expand Down Expand Up @@ -484,7 +484,7 @@ mod test {
(false, "500".to_string())
};
total_bytes += i;
successful_requests += if success { 1 } else { 0 };
successful_requests += i32::from(success);
total_requests += 1;

metrics.report_request(
Expand Down Expand Up @@ -592,7 +592,7 @@ mod test {
.with_body("world")
.create();

let url = mockito::server_url().to_string();
let url = mockito::server_url();
println!("Url: {}", url);

let reporter = PrometheusReporter::new(
Expand Down

0 comments on commit 73d3188

Please sign in to comment.