For a second, pretend we have GAT, Const Generics, and whatever your favorite type system feature is.
What numeric traits would make sense to have in std? What numeric traits would make sense to not have in std, but in a "2nd party" (i.e. officially endorced) crate? What numeric traits might be useful but can be relegated to a 3rd party crate?
I'm not really concerned with how the traits would be laid out. I'm interested in what functionality you think deserves to be standardized vocabulary for talking about types in programs.
num-traits is the current go-to for numerical traits, of which I'll reproduce a few highlights below:
NumOps: just an alias for Add+Sub+Div+Mul
Zero/One: additive and multiplicative identity
Float: operations that make sense on a floating point number
Real: mathematical real numbers without floating point oddities required
I personally think that abstractions for higher level mathematical concepts (rings, graphs, etc) aren't generally applicable enough to live in std, but basic numerics feels simple and universal to potentially deserve a spot in std.
Note that most of num was in std::num before Rust 1.0, but deemed unready for permanent stabilization that std requires. So that became the external crate, later split into the separate num-traits etc.
At the very least, all the methods of primitive number types should be defined in a trait in the standard library. For example, we could have Pow, Abs, Signum, IsPositive, IsNegative, MinValue, MaxValue traits, and so on.
Or, we could have bigger traits with more than one method, like Signed, Float, Int, Bounded.
Zero/One is nice to have, although I'm not sure if it's important enough to live in std.
Mind that moving traits to std makes it impossible to add a new required item. Float, Real, and PrimInt contain dozens of required items and it seems likely that we'd want to add new methods in the future.
NumOps I feel is too broad. It requires Mul, Div, and Rem, but these three traits satisfy different properties on integers versus floats.
What I find myself doing is writing some traits so that I can write generic code over the integer primitives. What I would find useful is having one large trait implementing all the functions common to the integers, or maybe having three traits: Int, IntSigned: Int and IntUnsigned: Int to handle methods that depend on signedness.
But then I would expect these traits to incorporate any new methods implemented for primitive integers, so they have to be somehow sealed. That means that for the traits I would like, it wouldn't be possible to implement them for external types.
Traits that can be implemented by external types have a different purpose, and it should always be clear whether a trait is intended to cover as much primitive methods as possible, or whether it is intended to be implemented by external types. These aims go against each other, that's why it needs to be clear which of the two kinds is the aim of a trait.
Having numeric traits std could've also helped to reduce number of methods, e.g. Duration has float related methods, and we essentially have to duplicate methods by introducing f32 and f64 variants instead of having a single generic version.
After thinking a bit more about this, this is what think I would like:
Lots of very specific traits, similar to the current Neg, Add, BitAndAssign, etc. These would be for example trait Abs, trait FromStrRadix, trait CheckedAdd and so on. These would already allow code to be generic over primitive integers, as all you would need to do is something like fn foo<I>(i: I) where I: CheckedAdd<Output = I> + Abs<Output = I>.
Not all traits would need to have just a single method. For example CheckedAdd could easily be
As a convenience feature, there could be some very broad traits, which should probably be sealed. They would have all the other relevant little specific traits as supertraits. That way someone could just write something like fn foo<I: Int>(i: I) and use all the features common to all integers. I'm not sure these need to be in std though, they could easily be in a crate.