Skip to content

Commit

Permalink
Dont reimplement saturating_sub (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
usbalbin authored Dec 2, 2024
1 parent 8e4188a commit ef7beeb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
9 changes: 0 additions & 9 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -164,7 +164,7 @@ where
#[inline]
pub fn skip<const SKIP: usize>(
self,
) -> IteratorFixed<impl Iterator<Item = I::Item>, { sub_or_zero(N, SKIP) }> {
) -> IteratorFixed<impl Iterator<Item = I::Item>, { N.saturating_sub(SKIP) }> {
IteratorFixed {
inner: self.inner.skip(SKIP),
}
Expand Down

0 comments on commit ef7beeb

Please sign in to comment.