Hash join: Difference between revisions

→‎{{header|Rust}}: Make more idiomatic
(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
(→‎{{header|Rust}}: Make more idiomatic)
Line 2,288:
 
=={{header|Rust}}==
<lang rust>use std::collections::HashMap;
use std::collections::HashMap;
 
fn main() {
Line 2,303 ⟶ 2,302:
let mut h = HashMap::new();
for (i, a) in table_a.iter().enumerate() {
h.entry(a.1).or_insertor_insert_with(vec![]Vec::new).push(i);
}
// join phase
for b in table_b {
forif ilet inSome(vals) = h.get(b.0).unwrap_or(&vec![]) {
letfor a&val =in table_a.get(*i).unwrap();vals {
println!("{:?} {:?}", let a, b= table_a.get(val).unwrap();
println!("{:?} {:?}", a, b);
}
}
}