Skip to content

std::ops - Operators

func mul

func mul(T, T): T
where T: AnyNumber

Multiplies two numbers.

func div

func div(T, T): T
where T: AnyNumber

Divides two numbers.

func mod

func mod(T, T): T
where T: AnyNumber

Division remainder.

func add

func add(T, T): T
where T: AnyNumber | Duration | Decimal

Adds two numbers.

func sub

func sub(T, T): T
where T: AnyNumber | Duration | Decimal

Subtracts two numbers.

func neg

func neg(T): T
where T: Int8 | Int16 | Int32 | Int64 | Float32 | Float64 | Duration

Negates a number.

func cmp

func cmp(T, T): Ordering
where T

Compare two values to determine if the first is less, equal, or greater than the second.

type Ordering

type Ordering: enum {less, equal, greater}

Result of a three-way comparison. Returned by cmp.

func eq

func eq(T, T): Bool
where T

Tests if values are equal. Used by == operator.

func ne

func ne(T, T): Bool
where T

Tests if values are not equal. Used by != operator.

func gt

func gt(T, T): Bool
where T

Tests if left value is greater than the right. Used by > operator.

func lt

func lt(T, T): Bool
where T

Tests if left value is less than the right. Used by < operator.

func gte

func gte(T, T): Bool
where T

Tests if left value is greater or equal to the right. Used by >= operator.

func lte

func lte(T, T): Bool
where T

Tests if left value is less or equal to the right. Used by <= operator.

func and

func and(Bool, Bool): Bool

Tests if both values are true. Used by && operator.

func or

func or(Bool, Bool): Bool

Tests if either of the values is true. Used by || operator.

func not

func not(Bool): Bool

Inverts a boolean. Used by ! operator.