We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 2c858a7 + 8034c45 commit bf61143Copy full SHA for bf61143
library/alloc/src/vec/is_zero.rs
@@ -2,7 +2,7 @@ use crate::boxed::Box;
2
3
#[rustc_specialization_trait]
4
pub(super) unsafe trait IsZero {
5
- /// Whether this value is zero
+ /// Whether this value's representation is all zeros
6
fn is_zero(&self) -> bool;
7
}
8
@@ -49,6 +49,13 @@ unsafe impl<T> IsZero for *mut T {
49
50
51
52
+unsafe impl<T: IsZero, const N: usize> IsZero for [T; N] {
53
+ #[inline]
54
+ fn is_zero(&self) -> bool {
55
+ self.iter().all(IsZero::is_zero)
56
+ }
57
+}
58
+
59
// `Option<&T>` and `Option<Box<T>>` are guaranteed to represent `None` as null.
60
// For fat pointers, the bytes that would be the pointer metadata in the `Some`
61
// variant are padding in the `None` variant, so ignoring them and
0 commit comments