Skip to main content

ExprCompare

Struct ExprCompare 

Source
pub struct ExprCompare {
    pub node_index: AtomicNodeIndex,
    pub range: TextRange,
    pub ops: Box<[CmpOp]>,
    pub operands: Box<[Expr]>,
    pub runtime_comparators: Option<Vec<Option<Expr>>>,
}
Expand description

A comparison or chain of comparisons.

operands contains all operands in source order, including the leftmost operand. For example, a < b <= c has operands [a, b, c] and operators [Lt, LtE]. There is at least one operator, and operands.len() == ops.len() + 1.

See also Compare.

Fields§

§node_index: AtomicNodeIndex§range: TextRange§ops: Box<[CmpOp]>§operands: Box<[Expr]>§runtime_comparators: Option<Vec<Option<Expr>>>

Implementations§

Source§

impl ExprCompare

Source

pub fn first_operand(&self) -> &Expr

Returns the initial operand (a in a < b <= c).

§Panics

Panics if there are no operands. The parser always produces at least two operands, synthesizing an invalid name expression for a missing operand during error recovery.

Source

pub fn second_operand(&self) -> &Expr

Returns the right operand of the first comparison (b in a < b <= c).

§Panics

Panics if there are fewer than two operands. See Self::first_operand.

Source

pub fn first_operator(&self) -> CmpOp

Returns the first comparison operator (< in a < b <= c).

§Panics

Panics if there are no operators. The parser always produces at least one operator.

Source

pub fn comparators(&self) -> &[Expr]

Returns all operands after the initial operand ([b, c] in a < b <= c).

§Panics

Panics if there are no operands. See Self::first_operand.

Source

pub fn as_single(&self) -> Option<(&Expr, &CmpOp, &Expr)>

Returns (left, operator, right) if there is exactly one operator and two operands.

Source

pub fn iter( &self, ) -> impl DoubleEndedIterator<Item = (&Expr, &CmpOp, &Expr)> + ExactSizeIterator

Iterates over each comparison as (left, operator, right).

For a < b <= c, yields (a, <, b) followed by (b, <=, c).

Trait Implementations§

Source§

impl Clone for ExprCompare

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ExprCompare

Source§

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

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

impl<'a> From<&'a ExprCompare> for ExprRef<'a>

Source§

fn from(node: &'a ExprCompare) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a ExprCompare> for AnyNodeRef<'a>

Source§

fn from(node: &'a ExprCompare) -> AnyNodeRef<'a>

Converts to this type from the input type.
Source§

impl From<ExprCompare> for Expr

Source§

fn from(node: ExprCompare) -> Self

Converts to this type from the input type.
Source§

impl HasNodeIndex for ExprCompare

Source§

fn node_index(&self) -> &AtomicNodeIndex

Returns the AtomicNodeIndex for this node.
Source§

impl PartialEq for ExprCompare

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Ranged for ExprCompare

Source§

fn range(&self) -> TextRange

The range of this item in the source text.
Source§

fn start(&self) -> TextSize

The start offset of this item in the source text.
Source§

fn end(&self) -> TextSize

The end offset of this item in the source text.
Source§

impl StructuralPartialEq for ExprCompare

Source§

impl<'a> TryFrom<AnyRootNodeRef<'a>> for &'a ExprCompare

Source§

type Error = ()

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

fn try_from(node: AnyRootNodeRef<'a>) -> Result<&'a ExprCompare, ()>

Performs the conversion.

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.