docs

You are reading the docs for v0.1.0. Nabi 0.1.0 is no longer supported. Latest release: v0.1.3 →

core::ops

On this page

Operator traits: the source of every operator token.

nabic binds each token to the trait method carrying its #[infix] / #[prefix] / #[postfix]; precedence and associativity are fixed by the language. #[lang(...)] binds each trait to a compiler slot.

Traits

AddSource

pub trait Add<Rhs = Self>

+: addition.

ModuloSource

pub trait Modulo<Rhs = Self>

%%: floored modulo - the result takes the divisor's sign, so a positive divisor gives [0, rhs) (Python's %). No lang slot.

SubSource

pub trait Sub<Rhs = Self>

-: subtraction.

MulSource

pub trait Mul<Rhs = Self>

*: multiplication.

DivSource

pub trait Div<Rhs = Self>

/: division.

RemSource

pub trait Rem<Rhs = Self>

%: truncated remainder - the result takes the dividend's sign.

PowSource

pub trait Pow<Rhs = Self>

**: power. Binds tighter than prefix - and to the right: -x**2 is -(x**2), 2**3**2 is 2**(3**2). An integer base takes a u32 exponent (overflow is the arithmetic's); a float base a float (pow) or an i32 (powi).

NegSource

pub trait Neg

Prefix -: negation.

NotSource

pub trait Not

Prefix !: logical not.

BitNotSource

pub trait BitNot

Prefix ~: bitwise not.

BitAndSource

pub trait BitAnd<Rhs = Self>

&: bitwise and.

BitOrSource

pub trait BitOr<Rhs = Self>

|: bitwise or.

BitXorSource

pub trait BitXor<Rhs = Self>

^: bitwise xor.

ShlSource

pub trait Shl<Rhs = Self>

<<: shift left.

ShrSource

pub trait Shr<Rhs = Self>

>>: shift right.

PartialEqSource

pub trait PartialEq<Rhs = Self>

== / !=: equality that may be partial (NaN is unequal to itself).

  • fn eq(self, rhs: Rhs) -> bool§

    Source

    Whether self equals rhs.

  • const fn ne(self, rhs: Rhs) -> bool§

    Source

    !=: !self.eq(rhs).

PartialOrdSource

pub trait PartialOrd<Rhs = Self>: PartialEq<Rhs>

<, >, <=, >=: an order that may be partial (NaN).

  • fn lt(self, rhs: Rhs) -> bool§

    Source

    Whether self is less than rhs.

  • fn gt(self, rhs: Rhs) -> bool§

    Source

    Whether self is greater than rhs.

  • fn le(self, rhs: Rhs) -> bool§

    Source

    Whether self is less than or equal to rhs.

  • fn ge(self, rhs: Rhs) -> bool§

    Source

    Whether self is greater than or equal to rhs.

  • const fn partial_cmp(self, rhs: Rhs) -> core::cmp::Ordering | none§

    Source

    The order, or none when the two are incomparable (NaN).

LogicalAndSource

pub trait LogicalAnd<Rhs = Self>

&& on a non-bool type; both sides are evaluated.

  • fn logical_and(self, rhs: Rhs) -> bool§

    Source

    self && rhs.

LogicalOrSource

pub trait LogicalOr<Rhs = Self>

|| on a non-bool type; both sides are evaluated.

  • fn logical_or(self, rhs: Rhs) -> bool§

    Source

    self || rhs.

CallSource

pub trait Call<Args>

A call v(a) on a value whose type is not a function: call(a). Args is the one argument's type, a tuple for several (v(a, b) is v.call((a, b))) and () for none. fn values and closures are called directly and need no impl.

AddAssignSource

pub trait AddAssign<Rhs = Self>

+=

  • fn add_assign(ref self, rhs: Rhs)§

    Source

    Adds rhs to self in place.

SubAssignSource

pub trait SubAssign<Rhs = Self>

-=

  • fn sub_assign(ref self, rhs: Rhs)§

    Source

    Subtracts rhs from self in place.

MulAssignSource

pub trait MulAssign<Rhs = Self>

*=

  • fn mul_assign(ref self, rhs: Rhs)§

    Source

    Multiplies self by rhs in place.

PowAssignSource

pub trait PowAssign<Rhs = Self>

**=

  • fn pow_assign(ref self, rhs: Rhs)§

    Source

    Raises self to rhs in place.

DivAssignSource

pub trait DivAssign<Rhs = Self>

/=

  • fn div_assign(ref self, rhs: Rhs)§

    Source

    Divides self by rhs in place.

RemAssignSource

pub trait RemAssign<Rhs = Self>

%=

  • fn rem_assign(ref self, rhs: Rhs)§

    Source

    Sets self to self % rhs.

ModuloAssignSource

pub trait ModuloAssign<Rhs = Self>

%%=

  • fn modulo_assign(ref self, rhs: Rhs)§

    Source

    Sets self to self %% rhs.

BitAndAssignSource

pub trait BitAndAssign<Rhs = Self>

&=

  • fn bitand_assign(ref self, rhs: Rhs)§

    Source

    Sets self to self & rhs.

BitOrAssignSource

pub trait BitOrAssign<Rhs = Self>

|=

  • fn bitor_assign(ref self, rhs: Rhs)§

    Source

    Sets self to self | rhs.

BitXorAssignSource

pub trait BitXorAssign<Rhs = Self>

^=

  • fn bitxor_assign(ref self, rhs: Rhs)§

    Source

    Sets self to self ^ rhs.

ShlAssignSource

pub trait ShlAssign<Rhs = Self>

<<=

  • fn shl_assign(ref self, rhs: Rhs)§

    Source

    Shifts self left by rhs in place.

ShrAssignSource

pub trait ShrAssign<Rhs = Self>

>>=

  • fn shr_assign(ref self, rhs: Rhs)§

    Source

    Shifts self right by rhs in place.

DotAddSource

pub trait DotAdd<Rhs = Self>

.+: element-wise addition.

DotSubSource

pub trait DotSub<Rhs = Self>

.-: element-wise subtraction.

DotMulSource

pub trait DotMul<Rhs = Self>

.*: element-wise multiplication.

DotPowSource

pub trait DotPow<Rhs = Self>

.**: element-wise power.

DotDivSource

pub trait DotDiv<Rhs = Self>

./: element-wise division.

DotRemSource

pub trait DotRem<Rhs = Self>

.%: element-wise truncated remainder.

DotModuloSource

pub trait DotModulo<Rhs = Self>

.%%: element-wise floored modulo.

DotEqSource

pub trait DotEq<Rhs = Self>

.==: element-wise equality.

DotNeSource

pub trait DotNe<Rhs = Self>

.!=: element-wise inequality.

DotLtSource

pub trait DotLt<Rhs = Self>

.<: element-wise less-than.

DotGtSource

pub trait DotGt<Rhs = Self>

.>: element-wise greater-than.

DotLeSource

pub trait DotLe<Rhs = Self>

.<=: element-wise less-or-equal.

DotGeSource

pub trait DotGe<Rhs = Self>

.>=: element-wise greater-or-equal.

DotLogicalAndSource

pub trait DotLogicalAnd<Rhs = Self>

.&& / .||: element-wise, both sides always evaluated.

DotLogicalOrSource

pub trait DotLogicalOr<Rhs = Self>

.||: element-wise or, both sides always evaluated.

DotBitAndSource

pub trait DotBitAnd<Rhs = Self>

.&: element-wise bitwise and.

DotBitOrSource

pub trait DotBitOr<Rhs = Self>

.|: element-wise bitwise or.

DotBitXorSource

pub trait DotBitXor<Rhs = Self>

.^: element-wise bitwise xor.

DotShlSource

pub trait DotShl<Rhs = Self>

.<<: element-wise shift left.

DotShrSource

pub trait DotShr<Rhs = Self>

.>>: element-wise shift right.

BroadcastableSource

pub trait Broadcastable<const N: usize>

An operand of a fused dot expression: its elements seen as an N-axis array, with no copy. A dot expression whose containers are all Broadcastable (and whose other operands are primitives, an element type or BroadcastScalar) runs as one loop with no intermediate arrays, and .= / .+= .. write into one in place. Array implements it; a type of your own that keeps its elements in an Array returns that. Implementing it promises that the type's dot operators act on the viewed elements as on plain values.

  • type Elem§

    Source
  • fn broadcast_view(self) -> core::array::Array<Elem, N>§

    Source

    The elements as an array: a view sharing the storage.

BroadcastScalarSource

pub trait BroadcastScalar

A scalar operand of a fused dot expression that wraps a number (a quantity with a unit): the loop applies broadcast_scalar to every element, as the type's dot operators would.

MaterializeSource

pub trait Materialize<U, const N: usize>

The container a fused dot expression returns: out holds the result's elements, U, in a fresh row-major array. A tree over arrays takes it from its leading operand (the first of the highest rank); a tree over types of your own from the type its dot operators give.

CrossSource

pub trait Cross<Rhs = Self>

×: cross product.

DotSource

pub trait Dot<Rhs = Self>

⋅: dot product.

ComposeSource

pub trait Compose<Rhs>

∘: function composition.

SqrtSource

pub trait Sqrt

Prefix √: square root.

ContainsSource

pub trait Contains<Item>

∈ / ∉: a ∈ s is s.contains(a) (swap).

  • fn contains(self, item: Item) -> bool§

    Source

    Whether self holds item.

  • const fn not_contains(self, item: Item) -> bool§

    Source

    ∉: !self.contains(item).

SubsetSource

pub trait Subset<Rhs = Self>

⊂ / ⊆: subset tests.

  • fn is_proper_subset(self, rhs: Rhs) -> bool§

    Source

    Whether every item of self is in rhs and rhs has more.

  • fn is_subset(self, rhs: Rhs) -> bool§

    Source

    Whether every item of self is in rhs.

UnionSource

pub trait Union<Rhs = Self>

∪: union.

IntersectSource

pub trait Intersect<Rhs = Self>

∩: intersection.