rust-num / num-traits

Numeric traits for generic mathematics in Rust
Apache License 2.0
719 stars 133 forks source link

Add constants Zero::ZERO and One::ONE #298

Closed Sympatron closed 11 months ago

Sympatron commented 11 months ago

Currently all trait methods are not usable in const contexts. Since zero is also the default value of all number types, this can be useful as a replacement for Default::default() in const contexts.

PS: Is there a reason that none of the traits provide constant versions of their values?

cuviper commented 11 months ago

It's a breaking change, and allocated types like bigint can't support this. See also #276.