module std::numbersource
The numeric constraint interface.
Number is a lang item (LANGUAGE_SPEC.md section 6.1a) at the canonical
path std::number::Number. The compiler satisfies it for the primitive
numeric types (section 4.1); it bounds generic type parameters
(fn add<T: Number>(...)) and the to conversion cast (section 4.5).
Its functions give the operators to a type that declares it (section
6.2): '+' calls add, '<' compares what compare gives, and so on. A
type implements only those it uses; a type over a numeric primitive
keeps the built-in operators and may override single ones.
interface Numbersource
exp interface Number
Required functions
fn add(self: &, other: &Self) -> Self;fn subtract(self: &, other: &Self) -> Self;fn multiply(self: &, other: &Self) -> Self;fn divide(self: &, other: &Self) -> Self;fn remainder(self: &, other: &Self) -> Self;fn negate(self: &) -> Self;fn compare(self: &, other: &Self) -> Ordering;
Implemented by
type Orderingsource
exp type Ordering = enum
How two values order: what compare gives.
Variants
LessEqualGreater