-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.
Description
I would like to dedup a Vec
of structs using a property of the struct. I do not want to map
since I want to maintain the contents of the Vec. The stdlib Vec can sort_by
using a comparator F: FnMut(&T, &T)
-- it would be consistent for Vec to dedup_by
using the same kind of comparator.
My contrived example:
#[derive(PartialEq)]
struct CoolThing( pub &'static str, pub u8 );
fn main(){
let mut things = vec![
CoolThing("Jimbo", 10), CoolThing("Billy", 10)
];
let uniq_things = things.dedup_by(|x| x.1);
assert!( vec![CoolThing("Billy",10)] == uniq_things )
}
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.