From f9ab0d2dd5f5fd2fb8ab02fbd43e894ff3ff568e Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Mon, 2 Dec 2024 15:27:21 +0100 Subject: [PATCH] Dont reimplement saturating_sub --- src/helpers.rs | 9 --------- src/lib.rs | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/helpers.rs b/src/helpers.rs index 0549a1b..20a0906 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -7,15 +7,6 @@ pub const fn min(a: usize, b: usize) -> usize { } } -#[cfg(feature = "nightly_features")] -pub const fn sub_or_zero(a: usize, b: usize) -> usize { - if a > b { - a - b - } else { - 0 - } -} - #[cfg(feature = "nightly_features")] pub const fn ceiling_div(x: usize, d: usize) -> usize { x / d + (x % d != 0) as usize diff --git a/src/lib.rs b/src/lib.rs index db3dfbc..2f0df22 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,7 +58,7 @@ mod helpers; mod into; #[cfg(feature = "nightly_features")] -use helpers::{ceiling_div, min, sub_or_zero}; +use helpers::{ceiling_div, min}; pub use from::FromIteratorFixed; pub use into::IntoIteratorFixed; @@ -164,7 +164,7 @@ where #[inline] pub fn skip( self, - ) -> IteratorFixed, { sub_or_zero(N, SKIP) }> { + ) -> IteratorFixed, { N.saturating_sub(SKIP) }> { IteratorFixed { inner: self.inner.skip(SKIP), }