Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate chrono;
- extern crate time;
- extern crate itertools;
- use chrono::prelude::*;
- use time::Duration;
- use itertools::Itertools;
- fn main() {
- let t = vec![Utc::now(), Utc::now()-Duration::seconds(30), Utc::now()-Duration::seconds(65), Utc::now()-Duration::seconds(80)];
- let v = vec![10.0, 20.0, 40.0, 30.0];
- let res = t.iter().zip(v.iter())
- .group_by(|(ts,_)| ts.minute())
- .into_iter()
- .filter_map(|(_, vs)| vs.map(|(_, &x)| x).minmax().into_option())
- .collect::<Vec<(f32,f32)>>(); // do not change type
- println!("{:?}", res);
- }
Add Comment
Please, Sign In to add comment