Skip to main content

ComparisonOperand

Trait ComparisonOperand 

Source
pub trait ComparisonOperand<'a, V, Expected>
where V: SQLParam + 'a, Expected: DataType,
{ type SQLType: DataType; type Aggregate: AggregateKind; // Required method fn into_comparison_sql(self) -> SQL<'a, V>; }
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§

Required Methods§

Source

fn into_comparison_sql(self) -> SQL<'a, V>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

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