1// The numeric constraint interface.2//3// Number is a lang item (LANGUAGE_SPEC.md section 6.1a) at the canonical4// path std::number::Number. The compiler satisfies it for the primitive5// numeric types (section 4.1); it bounds generic type parameters6// (`fn add<T: Number>(...)`) and the `to` conversion cast (section 4.5).7//8// Its functions give the operators to a type that declares it (section9// 6.2): `'+'` calls `add`, `'<'` compares what `compare` gives, and so on. A10// type implements only those it uses; a type over a numeric primitive11// keeps the built-in operators and may override single ones.1213exp interface Number {14 fn add(self: &, other: &Self) -> Self;15 fn subtract(self: &, other: &Self) -> Self;16 fn multiply(self: &, other: &Self) -> Self;17 fn divide(self: &, other: &Self) -> Self;18 fn remainder(self: &, other: &Self) -> Self;19 fn negate(self: &) -> Self;20 fn compare(self: &, other: &Self) -> Ordering;21}2223// How two values order: what `compare` gives.24exp type Ordering = enum {25 Less,26 Equal,27 Greater,28};