diff options
| author | Markus Reiter <me@reitermark.us> | 2024-01-29 23:59:09 +0100 |
|---|---|---|
| committer | Markus Reiter <me@reitermark.us> | 2024-02-15 08:09:42 +0100 |
| commit | 746a58d4359786e4aebb372a30829706fa5a968f (patch) | |
| tree | d8e13fb3fc93deb5aa964c863bad51f67937c104 /library/alloc/src/collections/binary_heap | |
| parent | ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46 (diff) | |
| download | rust-746a58d4359786e4aebb372a30829706fa5a968f.tar.gz rust-746a58d4359786e4aebb372a30829706fa5a968f.zip | |
Use generic `NonZero` internally.
Diffstat (limited to 'library/alloc/src/collections/binary_heap')
| -rw-r--r-- | library/alloc/src/collections/binary_heap/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/library/alloc/src/collections/binary_heap/mod.rs b/library/alloc/src/collections/binary_heap/mod.rs index 00a101541c5..3a82fb0df88 100644 --- a/library/alloc/src/collections/binary_heap/mod.rs +++ b/library/alloc/src/collections/binary_heap/mod.rs @@ -147,7 +147,7 @@ use core::alloc::Allocator; use core::fmt; use core::iter::{FusedIterator, InPlaceIterable, SourceIter, TrustedFused, TrustedLen}; use core::mem::{self, swap, ManuallyDrop}; -use core::num::NonZeroUsize; +use core::num::NonZero; use core::ops::{Deref, DerefMut}; use core::ptr; @@ -296,7 +296,7 @@ pub struct PeekMut< heap: &'a mut BinaryHeap<T, A>, // If a set_len + sift_down are required, this is Some. If a &mut T has not // yet been exposed to peek_mut()'s caller, it's None. - original_len: Option<NonZeroUsize>, + original_len: Option<NonZero<usize>>, } #[stable(feature = "collection_debug", since = "1.17.0")] @@ -350,7 +350,7 @@ impl<T: Ord, A: Allocator> DerefMut for PeekMut<'_, T, A> { // the standard library as "leak amplification". unsafe { // SAFETY: len > 1 so len != 0. - self.original_len = Some(NonZeroUsize::new_unchecked(len)); + self.original_len = Some(NonZero::<usize>::new_unchecked(len)); // SAFETY: len > 1 so all this does for now is leak elements, // which is safe. self.heap.data.set_len(1); @@ -1576,8 +1576,8 @@ unsafe impl<T, A: Allocator> SourceIter for IntoIter<T, A> { #[unstable(issue = "none", feature = "inplace_iteration")] #[doc(hidden)] unsafe impl<I, A: Allocator> InPlaceIterable for IntoIter<I, A> { - const EXPAND_BY: Option<NonZeroUsize> = NonZeroUsize::new(1); - const MERGE_BY: Option<NonZeroUsize> = NonZeroUsize::new(1); + const EXPAND_BY: Option<NonZero<usize>> = NonZero::<usize>::new(1); + const MERGE_BY: Option<NonZero<usize>> = NonZero::<usize>::new(1); } unsafe impl<I> AsVecIntoIter for IntoIter<I> { |
