Skip to content

std::subtract

Import with import std::subtract.

Interfaces

interface Subtract<Rhs, Out>
    fn subtract(lhs: self, rhs: Rhs) -> Out
end

The interface behind the - operator: lhs - rhs is Subtract.subtract(lhs, rhs).

The implementing type (self) is the left operand. Rhs is the right operand’s type and Out the result’s, so an impl can return a type other than its left operand’s.

pub type DateDay Int
pub type Days Int

impl Subtract<Days, DateDay> for DateDay
    fn subtract(lhs: DateDay, rhs: Days) -> DateDay
        ...
    end
end
fn subtract(lhs: self, rhs: Rhs) -> Out

interface Subtract