[][src]Struct codd::expression::Product

pub struct Product<L, R, Left, Right, T> where
    L: Tuple,
    R: Tuple,
    T: Tuple,
    Left: Expression<L>,
    Right: Expression<R>, 
{ /* fields omitted */ }

Corresponds to the cartesian product of two expression.

Example:

use codd::{Database, expression::Product};

let mut db = Database::new();
let r = db.add_relation::<i32>("R").unwrap();
let s = db.add_relation::<i32>("S").unwrap();

db.insert(&r, vec![0, 1, 2].into());
db.insert(&s, vec![2, 4].into());

let prod = Product::new(&r, &s, |l, r| l*r);

assert_eq!(vec![0, 2, 4, 8], db.evaluate(&prod).unwrap().into_tuples());

Implementations

impl<L, R, Left, Right, T> Product<L, R, Left, Right, T> where
    L: Tuple,
    R: Tuple,
    T: Tuple,
    Left: Expression<L>,
    Right: Expression<R>, 
[src]

pub fn new<IL, IR>(
    left: IL,
    right: IR,
    project: impl FnMut(&L, &R) -> T + 'static
) -> Self where
    IL: IntoExpression<L, Left>,
    IR: IntoExpression<R, Right>, 
[src]

Creates a Product expression over left and right with mapper as the closure that produces the tuples of the resulting expression from tuples of left and right.

pub fn left(&self) -> &Left[src]

Returns a reference to the left sub-expression.

pub fn right(&self) -> &Right[src]

Returns a reference to the right sub-expression.

pub fn mapper_mut(&self) -> RefMut<'_, dyn FnMut(&L, &R) -> T>[src]

Returns a mutable reference (of type std::cell::RefMut) to the mapping closure.

Trait Implementations

impl<L: Clone, R: Clone, Left: Clone, Right: Clone, T: Clone> Clone for Product<L, R, Left, Right, T> where
    L: Tuple,
    R: Tuple,
    T: Tuple,
    Left: Expression<L>,
    Right: Expression<R>, 
[src]

impl<L, R, Left, Right, T> Debug for Product<L, R, Left, Right, T> where
    L: Tuple,
    R: Tuple,
    T: Tuple,
    Left: Expression<L>,
    Right: Expression<R>, 
[src]

impl<L, R, Left, Right, T> Expression<T> for Product<L, R, Left, Right, T> where
    L: Tuple,
    R: Tuple,
    T: Tuple,
    Left: Expression<L>,
    Right: Expression<R>, 
[src]

impl<T: Tuple> From<Product<T, T, Mono<T>, Mono<T>, T>> for Mono<T>[src]

Auto Trait Implementations

impl<L, R, Left, Right, T> !RefUnwindSafe for Product<L, R, Left, Right, T>

impl<L, R, Left, Right, T> !Send for Product<L, R, Left, Right, T>

impl<L, R, Left, Right, T> !Sync for Product<L, R, Left, Right, T>

impl<L, R, Left, Right, T> Unpin for Product<L, R, Left, Right, T> where
    Left: Unpin,
    Right: Unpin

impl<L, R, Left, Right, T> !UnwindSafe for Product<L, R, Left, Right, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, E> IntoExpression<T, E> for E where
    E: Expression<T>,
    T: Tuple
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.