Skip to content

Commit

Permalink
implement IsZero for Saturating and Wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
asquared31415 committed Sep 2, 2022
1 parent 9ba169a commit 80e035c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
#![feature(ptr_metadata)]
#![feature(ptr_sub_ptr)]
#![feature(receiver_trait)]
#![feature(saturating_int_impl)]
#![feature(set_ptr_value)]
#![feature(slice_from_ptr_range)]
#![feature(slice_group_by)]
Expand Down
16 changes: 16 additions & 0 deletions library/alloc/src/vec/is_zero.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::num::{Saturating, Wrapping};

use crate::boxed::Box;

#[rustc_specialization_trait]
Expand Down Expand Up @@ -144,3 +146,17 @@ impl_is_zero_option_of_nonzero!(
NonZeroUsize,
NonZeroIsize,
);

unsafe impl<T: IsZero> IsZero for Wrapping<T> {
#[inline]
fn is_zero(&self) -> bool {
self.0.is_zero()
}
}

unsafe impl<T: IsZero> IsZero for Saturating<T> {
#[inline]
fn is_zero(&self) -> bool {
self.0.is_zero()
}
}

0 comments on commit 80e035c

Please sign in to comment.