#[rustc_specialization_trait]
pub(super) unsafe trait IsZero {
- /// Whether this value is zero
+ /// Whether this value's representation is all zeros
fn is_zero(&self) -> bool;
}
}
}
+unsafe impl<T: IsZero, const N: usize> IsZero for [T; N] {
+ #[inline]
+ fn is_zero(&self) -> bool {
+ self.iter().all(IsZero::is_zero)
+ }
+}
+
// `Option<&T>` and `Option<Box<T>>` are guaranteed to represent `None` as null.
// For fat pointers, the bytes that would be the pointer metadata in the `Some`
// variant are padding in the `None` variant, so ignoring them and