pub trait Zero: Sized {
// Required methods
fn zero() -> Self;
fn set_zero(&mut self);
fn is_zero(&self) -> bool;
}Expand description
Defines an additive identity element for Self.
This is a pure identity-value trait: it provides the 0 and a zero-test,
but does not require Add. The bundling of Add is
upstream convention, not a law — 0 is equally the identity under
subtraction (a - 0 = a) — so consumers state the operators they actually
use explicitly (T: Zero + Add, T: Zero + Sub, …). Numeric code that
needs the full operator set takes Num.
§Laws
a + 0 = a ∀ a ∈ Self
0 + a = a ∀ a ∈ SelfRequired Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".