std::divide
Import with import std::divide.
Exports
Section titled “Exports”Interfaces
interface Divide
Section titled “interface Divide”interface Divide<Rhs, Out> fn divide(lhs: self, rhs: Rhs) -> Out end
Protocol for the / operator.
Divide.divide(lhs, rhs) returns the result of lhs / rhs. The left-hand
type is the implementor (self); the interface type parameters describe
the right-hand operand and the output type. That lets an impl choose a
result that is not necessarily the same type as the left-hand operand.
The std impls for Int, Decimal and Duration take a divisor type
that leaves out zero (NonZeroInt, NonZeroDecimal), so n / 0 is a
compile error and a divisor computed while the program runs goes
through NonZeroInt.try_from. Float’s takes any Float, and dividing by
0.0 gives an infinity or NaN.
pub type Ratio Decimal pub type Scale Decimal impl Divide<Scale, Ratio> for Ratio fn divide(lhs: Ratio, rhs: Scale) -> Ratio ... end end
Divide.divide
Section titled “Divide.divide”fn divide(lhs: self, rhs: Rhs) -> Out
interface Divide