pub enum Op {
Show 34 variants
Query,
Pow,
BitNot,
Plus,
Minus,
Borrow,
Share,
Clone,
Mul,
Div,
Rem,
Add,
Sub,
SL,
ASR,
LSR,
BitAnd,
BitXor,
BitOr,
Cast,
Exclusive,
Inclusive,
LT,
GT,
LE,
GE,
LG,
EQ,
NE,
In,
BoolNot,
BoolAnd,
BoolOr,
Missing,
}Expand description
Represents one of Welly’s arithmetic operations. See also Operator.
Variants§
Query
OK(x)? is x; ERR(x)? returns ERR(x).
Pow
(-7) ** 2 is 49.
BitNot
~3 is -4.
Plus
+3 is 3.
Minus
-3 is -3.
Borrow
&x is borrowed.
$x is shared.
Clone
*x is a fresh copy of x.
Mul
-7 * 2 is -14.
Div
-7 / 2 is -4.
Rem
-7 % 2 is 1.
Add
3 + 5 is 8.
Sub
3 - 5 is -2.
SL
-7 << 2 is -28.
ASR
-7 >> 2 is -2.
LSR
-7 >>> 2 is (1 << 62) - 2.
BitAnd
3 & 5 is 1.
BitXor
3 ^ 5 is 6.
BitOr
3 | 5 is 7.
Cast
x: t - A value x cast to a type t.
Exclusive
0..3 means 0, 1, 2.
Inclusive
0...3 means 0, 1, 2, 3.
LT
3 < 5 is true.
GT
5 > 3 is true.
LE
3 <= 5 is true.
GE
5 >= 3 is true.
LG
3 <> 5 is true.
EQ
3 == 5 is false.
NE
3 != 5 is true.
In
item in collection - Membership test.
Also abused as part of for item in collection { ... }.
BoolNot
not false is true.
BoolAnd
false and true is false.
BoolOr
false or true is true.
Missing
Used when two expressions are juxtaposed. Always an error.
Implementations§
Source§impl Op
impl Op
Sourcepub const fn precedence(self) -> (Option<Precedence>, Option<Precedence>)
pub const fn precedence(self) -> (Option<Precedence>, Option<Precedence>)
Returns the left and right Precedence of self.
Differences from Rust and Python:
x in low .. high and bmeans(x in (low .. high)) and b.- In Rust, there is no
in.low .. high && bmeanslow .. (high && b). - In Python,
:is part of array subscription.a[x in low : high and b]meansa[(x in low) : (high and b)].
- In Rust, there is no
Differences from C, Java and Javascript:
x & 1 == 0means(x & 1) == 0.- In C, Java and Javascript it means
x & (1 == 0).
- In C, Java and Javascript it means
-x ** 2means-(x ** 2)- In Javascript it means
(-x) ** 2.
- In Javascript it means