pub enum LogicalOperator {
And,
Or,
}Expand description
Defines the type of logical operation.
Used by the LogicalOp variant of AstExpr to specify which logical operation
should be performed with short-circuit evaluation semantics.
§Short-Circuit Evaluation
Short-circuit evaluation is an optimization technique where the second operand of a logical operation is evaluated only when necessary:
-
For
&&(AND): If the left operand is false, the result is false regardless of the right operand, so the right operand is not evaluated. -
For
||(OR): If the left operand is true, the result is true regardless of the right operand, so the right operand is not evaluated.
This behavior is particularly useful for:
- Performance optimization - avoid unnecessary calculation
- Conditional execution - control evaluation of expressions
- Safe guards - prevent errors (e.g., division by zero)
§Boolean Representation
In this expression engine, boolean values are represented as floating-point numbers:
0.0representsfalse- Any non-zero value (typically
1.0) representstrue
Variants§
And
Logical AND (&&) - evaluates to true only if both operands are true. Short-circuits if the left operand is false.
Examples:
1 && 1evaluates to1.0(true)1 && 0evaluates to0.0(false)0 && exprevaluates to0.0without evaluatingexpr
Or
Logical OR (||) - evaluates to true if either operand is true. Short-circuits if the left operand is true.
Examples:
1 || 0evaluates to1.0(true)0 || 0evaluates to0.0(false)1 || exprevaluates to1.0without evaluatingexpr
Trait Implementations§
Source§impl Clone for LogicalOperator
impl Clone for LogicalOperator
Source§fn clone(&self) -> LogicalOperator
fn clone(&self) -> LogicalOperator
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LogicalOperator
impl Debug for LogicalOperator
Source§impl Display for LogicalOperator
Implements Display for LogicalOperator to use in error messages.
impl Display for LogicalOperator
Implements Display for LogicalOperator to use in error messages.
Source§impl PartialEq for LogicalOperator
impl PartialEq for LogicalOperator
impl StructuralPartialEq for LogicalOperator
Auto Trait Implementations§
impl Freeze for LogicalOperator
impl RefUnwindSafe for LogicalOperator
impl Send for LogicalOperator
impl Sync for LogicalOperator
impl Unpin for LogicalOperator
impl UnwindSafe for LogicalOperator
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)