about summary refs log tree commit diff
diff options
context:
space:
mode:
authorasquared31415 <34665709+asquared31415@users.noreply.github.com>2022-09-02 18:53:20 -0400
committerasquared31415 <34665709+asquared31415@users.noreply.github.com>2022-09-02 19:55:01 -0400
commit80e035c9e4f43bba282ec061dcbeae44ddb20f5f (patch)
tree7c49b84d7362aafe52ed6735d65c34f37e32e0b4
parent9ba169a73acfa9c9875b76eec09e9a91cc6246df (diff)
downloadrust-80e035c9e4f43bba282ec061dcbeae44ddb20f5f.tar.gz
rust-80e035c9e4f43bba282ec061dcbeae44ddb20f5f.zip
implement IsZero for Saturating and Wrapping
-rw-r--r--library/alloc/src/lib.rs1
-rw-r--r--library/alloc/src/vec/is_zero.rs16
2 files changed, 17 insertions, 0 deletions
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs
index ad6d19bbc68..e5cf9033c86 100644
--- a/library/alloc/src/lib.rs
+++ b/library/alloc/src/lib.rs
@@ -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)]
diff --git a/library/alloc/src/vec/is_zero.rs b/library/alloc/src/vec/is_zero.rs
index 92a32779b8e..2e025c8a4a5 100644
--- a/library/alloc/src/vec/is_zero.rs
+++ b/library/alloc/src/vec/is_zero.rs
@@ -1,3 +1,5 @@
+use core::num::{Saturating, Wrapping};
+
 use crate::boxed::Box;
 
 #[rustc_specialization_trait]
@@ -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()
+    }
+}