diff --git a/src/main.rs b/src/main.rs index ae30501..ce1dfe7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -141,11 +141,7 @@ impl DisplayBox { let kl = key.as_ref().len(); let vl = value.as_ref().len(); let total = kl + vl + 6; // two vertical bars, two edge spaces, colon space in centre - let spacing = if total < self.width { - self.width - total - } else { - 0 - }; + let spacing = self.width.saturating_sub(total); let mut spacer = String::new(); for _ in 0..spacing { spacer.push(' '); @@ -160,7 +156,7 @@ impl DisplayBox { fn edge(width: usize, top: bool, fg: Color) { let mut line = String::new(); - let hyphens = if width > 2 { width - 2 } else { 0 }; + let hyphens = width.saturating_sub(2); if top { line.push('/'); } else { @@ -271,7 +267,7 @@ impl AvailableArtifactStore { .log(id) .map(|x| x.raw()) .flatten_stream() - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)), + .map_err(std::io::Error::other), )) } @@ -283,13 +279,10 @@ impl AvailableArtifactStore { self.lava .job_results_as_junit(id) .map(|res| match res { - Ok(s) => s - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)) - .boxed(), - Err(e) => futures::stream::once(async move { - Err(std::io::Error::new(std::io::ErrorKind::Other, e)) - }) - .boxed(), + Ok(s) => s.map_err(std::io::Error::other).boxed(), + Err(e) => { + futures::stream::once(async move { Err(std::io::Error::other(e)) }).boxed() + } }) .flatten_stream(), ) @@ -647,7 +640,7 @@ impl Run { .job_results_as_junit(id) .await .map_err(|_| ())? - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)), + .map_err(std::io::Error::other), ) .into_async_read() .read_to_end(&mut bytes) diff --git a/src/throttled.rs b/src/throttled.rs index 1c73b28..9a51cbf 100644 --- a/src/throttled.rs +++ b/src/throttled.rs @@ -222,17 +222,17 @@ impl ThrottledLava { self.inner.tags().await } - pub async fn devices(&self) -> Throttled { + pub async fn devices(&self) -> Throttled<'_, Devices<'_>> { let permit = self.throttler.acquire("devices").await; Throttled::new(self.inner.devices(), permit) } - pub async fn log(&self, id: i64) -> ThrottledJobLogBuilder { + pub async fn log(&self, id: i64) -> ThrottledJobLogBuilder<'_> { let permit = self.throttler.acquire("log").await; ThrottledJobLogBuilder::new(self.inner.log(id), permit) } - pub async fn jobs(&self) -> ThrottledJobsBuilder { + pub async fn jobs(&self) -> ThrottledJobsBuilder<'_> { let permit = self.throttler.acquire("jobs").await; ThrottledJobsBuilder::new(self.inner.jobs(), permit) } @@ -255,7 +255,7 @@ impl ThrottledLava { job::job_results_as_junit(&self.inner, id).await } - pub async fn workers(&self) -> Throttled> { + pub async fn workers(&self) -> Throttled<'_, Paginator> { let permit = self.throttler.acquire("workers").await; Throttled::new(self.inner.workers(), permit) }