Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont reimplement saturating_sub #29

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading