implement IsZero for Saturating and Wrapping
This commit is contained in:
parent
9ba169a73a
commit
80e035c9e4
@ -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)]
|
||||||
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user