Use generic NonZero internally.

This commit is contained in:
Markus Reiter
2024-01-29 23:59:09 +01:00
parent ee9c7c940c
commit 746a58d435
144 changed files with 653 additions and 604 deletions

View File

@@ -1,6 +1,6 @@
//! Defines the `IntoIter` owned iterator for arrays.
use crate::num::NonZeroUsize;
use crate::num::NonZero;
use crate::{
fmt,
intrinsics::transmute_unchecked,
@@ -280,7 +280,7 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> {
self.next_back()
}
fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize> {
fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
// This also moves the start, which marks them as conceptually "dropped",
// so if anything goes bad then our drop impl won't double-free them.
let range_to_drop = self.alive.take_prefix(n);
@@ -292,7 +292,7 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> {
ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(slice));
}
NonZeroUsize::new(remaining).map_or(Ok(()), Err)
NonZero::<usize>::new(remaining).map_or(Ok(()), Err)
}
#[inline]
@@ -335,7 +335,7 @@ impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, N> {
})
}
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZeroUsize> {
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
// This also moves the end, which marks them as conceptually "dropped",
// so if anything goes bad then our drop impl won't double-free them.
let range_to_drop = self.alive.take_suffix(n);
@@ -347,7 +347,7 @@ impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, N> {
ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(slice));
}
NonZeroUsize::new(remaining).map_or(Ok(()), Err)
NonZero::<usize>::new(remaining).map_or(Ok(()), Err)
}
}