pub struct Join<K, L, R, Left, Right, T>{ /* private fields */ }Expand description
Represents the join of its left and right sub-expressions.
Example:
use codd::{Database, expression::Join};
let mut db = Database::new();
let fruit = db.add_relation::<(i32, String)>("R").unwrap();
let numbers = db.add_relation::<i32>("S").unwrap();
db.insert(&fruit, vec![
(0, "Apple".to_string()),
(1, "Banana".to_string()),
(2, "Cherry".to_string())
].into());
db.insert(&numbers, vec![0, 2].into());
let join = Join::new(
&fruit,
&numbers,
|t| t.0, // first element of tuples in `r` is the key for join
|&t| t, // the values in `s` are keys for join
// make resulting values from key `k`, left value `l` and right value `r`:
|k, l, r| format!("{}{}", l.1, k + r)
);
assert_eq!(vec!["Apple0", "Cherry4"], db.evaluate(&join).unwrap().into_tuples());Implementations§
Source§impl<K, L, R, Left, Right, T> Join<K, L, R, Left, Right, T>
impl<K, L, R, Left, Right, T> Join<K, L, R, Left, Right, T>
Sourcepub fn new<IL, IR>(
left: IL,
right: IR,
left_key: impl FnMut(&L) -> K + 'static,
right_key: impl FnMut(&R) -> K + 'static,
mapper: impl FnMut(&K, &L, &R) -> T + 'static,
) -> Selfwhere
IL: IntoExpression<L, Left>,
IR: IntoExpression<R, Right>,
pub fn new<IL, IR>(
left: IL,
right: IR,
left_key: impl FnMut(&L) -> K + 'static,
right_key: impl FnMut(&R) -> K + 'static,
mapper: impl FnMut(&K, &L, &R) -> T + 'static,
) -> Selfwhere
IL: IntoExpression<L, Left>,
IR: IntoExpression<R, Right>,
Creates a new Join expression over left and right where left_key
and right_key are closures that return the join key for tuples of
left and right respectively. The closure mapper computes the tuples
of the resulting expression from the join key and the tuples of left and
right.
Trait Implementations§
Source§impl<K, L, R, Left, Right, T> Expression<T> for Join<K, L, R, Left, Right, T>
impl<K, L, R, Left, Right, T> Expression<T> for Join<K, L, R, Left, Right, T>
Auto Trait Implementations§
impl<K, L, R, Left, Right, T> Freeze for Join<K, L, R, Left, Right, T>
impl<K, L, R, Left, Right, T> !RefUnwindSafe for Join<K, L, R, Left, Right, T>
impl<K, L, R, Left, Right, T> !Send for Join<K, L, R, Left, Right, T>
impl<K, L, R, Left, Right, T> !Sync for Join<K, L, R, Left, Right, T>
impl<K, L, R, Left, Right, T> Unpin for Join<K, L, R, Left, Right, T>
impl<K, L, R, Left, Right, T> UnsafeUnpin for Join<K, L, R, Left, Right, T>where
Left: UnsafeUnpin,
Right: UnsafeUnpin,
impl<K, L, R, Left, Right, T> !UnwindSafe for Join<K, L, R, Left, Right, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, E> IntoExpression<T, E> for Ewhere
T: Tuple,
E: Expression<T>,
impl<T, E> IntoExpression<T, E> for Ewhere
T: Tuple,
E: Expression<T>,
Source§fn into_expression(self) -> E
fn into_expression(self) -> E
Consumes the receiver and returns an expression.