Skip to main content

ComparisonOperand

Trait ComparisonOperand 

Source
pub trait ComparisonOperand<'a, V, Expected>: ToSQL<'a, V>
where V: SQLParam + 'a, Expected: DataType,
{ type SQLType: DataType; type Aggregate: AggregateKind; }
Expand description

Type-safe operand for comparison functions.

This trait exists as an indirection layer between comparison functions (eq, gt, like, etc.) and the Expr trait. Rather than accepting any Expr directly, comparisons require ComparisonOperand<'a, V, Expected> where Expected is the left-hand side’s SQL type.

The blanket impl below only fires when Expected: Compatible<R::SQLType>, so passing an incompatible type (e.g. comparing Int with Text) fails at compile time with a clear diagnostic.

Required Associated Types§

Implementors§

Source§

impl<'a, V, Expected, R> ComparisonOperand<'a, V, Expected> for R
where V: SQLParam + 'a, Expected: DataType + Compatible<R::SQLType>, R: Expr<'a, V>,

Source§

type SQLType = <R as Expr<'a, V>>::SQLType

Source§

type Aggregate = <R as Expr<'a, V>>::Aggregate