joinable
joinable is a Rust trait for joining iterables of values. Just as you can join two database tables in SQL to produce matching records from each, joinable provides you with simple functionality to achive the same in your Rust code:
use Joinable;
let joined = customers
.iter
.inner_join
.map
.;
joinable joins two expressions - the left-hand-side (LHS) and right-hand-side (RHS). The trait provides four functions:
inner_join-- emit each value in LHS with one or more matching RHS recordsouter_join-- emit each value in LHS with zero or more matching RHS recordssemi_join-- emit each value in LHS if and only if RHS has a matching recordanti_join-- emit each value in LHS if and only if RHS does not have a matching record
All four functions operate on an Iterator<Item=L> for LHS and accept an Into<RHS<R>>, which can take a slice &[R]. If you know your RHS is sorted according to your join condition, you can optionally create an explicitly ordered RHS:
let orders = RHSnew_sorted;
let joined = customers
.iter
.inner_join;
This permits binary searching of the RHS.