BinaryOperator

Enum BinaryOperator 

Source
pub enum BinaryOperator<'s> {
Show 29 variants Assign(&'s Token<'s>), AssignNewSlot(&'s Token<'s>, &'s Token<'s>), AssignAdd(&'s Token<'s>), AssignSubtract(&'s Token<'s>), AssignMultiply(&'s Token<'s>), AssignDivide(&'s Token<'s>), AssignModulo(&'s Token<'s>), Add(&'s Token<'s>), Subtract(&'s Token<'s>), Multiply(&'s Token<'s>), Divide(&'s Token<'s>), Modulo(&'s Token<'s>), Equal(&'s Token<'s>), NotEqual(&'s Token<'s>), Less(&'s Token<'s>), LessEqual(&'s Token<'s>), Greater(&'s Token<'s>), GreaterEqual(&'s Token<'s>), ThreeWay(&'s Token<'s>), LogicalAnd(&'s Token<'s>), LogicalOr(&'s Token<'s>), BitwiseAnd(&'s Token<'s>), BitwiseOr(&'s Token<'s>), BitwiseXor(&'s Token<'s>), ShiftLeft(&'s Token<'s>, &'s Token<'s>), ShiftRight(&'s Token<'s>, &'s Token<'s>), UnsignedShiftRight(&'s Token<'s>, &'s Token<'s>, &'s Token<'s>), In(&'s Token<'s>), Instanceof(&'s Token<'s>),
}
Expand description

A binary operator in a BinaryExpression.

There are six categories of binary operator:

  • Assignment - includes =, <-, +=, etc.
  • Math - includes +, -, *, / and %.
  • Comparison - includes ==, !=, <, <=, etc.
  • Logical - includes && and ||.
  • Bitwise - includes &, |, ^, <<, >> and >>>.
  • Test - includes in and instanceof.

Each operator has a precedence which defines how it is parsed as part of a longer expression.

Variants§

§

Assign(&'s Token<'s>)

Grammar: =

§

AssignNewSlot(&'s Token<'s>, &'s Token<'s>)

Grammar: < -

§

AssignAdd(&'s Token<'s>)

Grammar: +=

§

AssignSubtract(&'s Token<'s>)

Grammar: -=

§

AssignMultiply(&'s Token<'s>)

Grammar: *=

§

AssignDivide(&'s Token<'s>)

Grammar: /=

§

AssignModulo(&'s Token<'s>)

Grammar: %=

§

Add(&'s Token<'s>)

Grammar: +

§

Subtract(&'s Token<'s>)

Grammar: -

§

Multiply(&'s Token<'s>)

Grammar: *

§

Divide(&'s Token<'s>)

Grammar: /

§

Modulo(&'s Token<'s>)

Grammar: %

§

Equal(&'s Token<'s>)

Grammar: ==

§

NotEqual(&'s Token<'s>)

Grammar: !=

§

Less(&'s Token<'s>)

Grammar: <

§

LessEqual(&'s Token<'s>)

Grammar: <=

§

Greater(&'s Token<'s>)

Grammar: >

§

GreaterEqual(&'s Token<'s>)

Grammar: >=

§

ThreeWay(&'s Token<'s>)

Grammar: <=>

§

LogicalAnd(&'s Token<'s>)

Grammar: &&

§

LogicalOr(&'s Token<'s>)

Grammar: ||

§

BitwiseAnd(&'s Token<'s>)

Grammar: &

§

BitwiseOr(&'s Token<'s>)

Grammar: |

§

BitwiseXor(&'s Token<'s>)

Grammar: ^

§

ShiftLeft(&'s Token<'s>, &'s Token<'s>)

Grammar: < <

§

ShiftRight(&'s Token<'s>, &'s Token<'s>)

Grammar: > >

§

UnsignedShiftRight(&'s Token<'s>, &'s Token<'s>, &'s Token<'s>)

Grammar: > > >

§

In(&'s Token<'s>)

Grammar: in

§

Instanceof(&'s Token<'s>)

Grammar: instanceof

Implementations§

Source§

impl<'s> BinaryOperator<'s>

Source

pub fn precedence(self) -> Precedence

Returns the Precedence of the operator.

Trait Implementations§

Source§

impl<'s> Clone for BinaryOperator<'s>

Source§

fn clone(&self) -> BinaryOperator<'s>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'s> Debug for BinaryOperator<'s>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'s> PartialEq for BinaryOperator<'s>

Source§

fn eq(&self, other: &BinaryOperator<'s>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'s> Copy for BinaryOperator<'s>

Source§

impl<'s> StructuralPartialEq for BinaryOperator<'s>

Auto Trait Implementations§

§

impl<'s> Freeze for BinaryOperator<'s>

§

impl<'s> RefUnwindSafe for BinaryOperator<'s>

§

impl<'s> Send for BinaryOperator<'s>

§

impl<'s> Sync for BinaryOperator<'s>

§

impl<'s> Unpin for BinaryOperator<'s>

§

impl<'s> UnwindSafe for BinaryOperator<'s>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.