For reference. I finally got things going below. Thanks for all the help.
let data : Vec<(_,_)> = rows.into_iter()
.map( |row| (row.get::<_, DateTime<Utc>>(0), row.get::<_, i32>(1), row.get::<_, f64>(2)))
.group_by(|t| (t.1, BmosConnection::floor_by_granularity(t.0, time_granularity)))
.map(|group| (group.0, group.1 )).collect();
for (key, group) in data {
let values : Vec<f64> = group.iter().map(|v| v.2).collect();
let mut agg = get_agg(Aggregate::SUM);
let result : f64 = agg(values.iter());
println!("key {:?} --- {:?} ---- {} ", key, values, result);
}
Interestingly I hit a weird issue ?
If vec here is defined after agg the compile fails. Ie
let v = vec![2.0, 4.0];
let mut agg = get_agg(Aggregate::SUM);
// let v = vec![2.0, 4.0]; Fails in this position
let r : f64 = agg(v.iter());
Issue is https://github.com/rust-lang/rust/issues/38915 I believe.
I don’t seem to be very lucky with this piece of code but have learnt a few things :)