implement IsZero for Saturating and Wrapping

This commit is contained in:
asquared31415 2022-09-02 18:53:20 -04:00
parent 9ba169a73a
commit 80e035c9e4
2 changed files with 17 additions and 0 deletions

View File

@ -134,6 +134,7 @@
#![feature(ptr_metadata)] #![feature(ptr_metadata)]
#![feature(ptr_sub_ptr)] #![feature(ptr_sub_ptr)]
#![feature(receiver_trait)] #![feature(receiver_trait)]
#![feature(saturating_int_impl)]
#![feature(set_ptr_value)] #![feature(set_ptr_value)]
#![feature(slice_from_ptr_range)] #![feature(slice_from_ptr_range)]
#![feature(slice_group_by)] #![feature(slice_group_by)]

View File

@ -1,3 +1,5 @@
use core::num::{Saturating, Wrapping};
use crate::boxed::Box; use crate::boxed::Box;
#[rustc_specialization_trait] #[rustc_specialization_trait]
@ -144,3 +146,17 @@ fn is_zero(&self) -> bool {
NonZeroUsize, NonZeroUsize,
NonZeroIsize, 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()
}
}