3 use std::marker::PhantomData;
5 pub trait Scalar: 'static {
6 type RefType<'a>: ScalarRef<'a>;
9 pub trait ScalarRef<'a>: 'a {}
12 type RefType<'a> = i32;
15 impl Scalar for String {
16 type RefType<'a> = &'a str;
19 impl Scalar for bool {
20 type RefType<'a> = i32;
23 impl<'a> ScalarRef<'a> for bool {}
25 impl<'a> ScalarRef<'a> for i32 {}
27 impl<'a> ScalarRef<'a> for &'a str {}
29 fn str_contains(a: &str, b: &str) -> bool {
33 pub struct BinaryExpression<A: Scalar, B: Scalar, O: Scalar, F>
35 F: Fn(A::RefType<'_>, B::RefType<'_>) -> O,
38 _phantom: PhantomData<(A, B, O)>,
41 impl<A: Scalar, B: Scalar, O: Scalar, F> BinaryExpression<A, B, O, F>
43 F: Fn(A::RefType<'_>, B::RefType<'_>) -> O,
45 pub fn new(f: F) -> Self {
48 _phantom: PhantomData,
54 BinaryExpression::<String, String, bool, _>::new(str_contains);