help me: match tracks.isempty() { true => { bail!("No blacklisted tracks found.") }…
- User
help me:
match tracks.is_empty() {
true => {
bail!("No blacklisted tracks found.")
}
false => {
// sort by start in descending order
tracks.par_iter_mut().for_each(|(_, v)| {
v.par_sort_unstable_by(|a, b| a.0.cmp(&b.0));
});
info!(
"Parsed {} blacklisted tracks.",
tracks.values().flatten().count()
);
Ok(tracks)
}
error[E0308]: mismatched types
--> src/track.rs:157:16
|
157 | Ok(tracks)
| -- ^^^^^^ expected HashMap<String, HashSet<(u64, u64)>>, found HashMap<String, Vec<(u64, u64)>>
| |
| arguments to this enum variant are incorrect
|
= note: expected struct hashbrown::HashMap<_, hashbrown::HashSet<(u64, u64)>>
found struct hashbrown::HashMap<_, Vec<(u64, u64)>>
help: the type constructed contains hashbrown::HashMap<std::string::String, Vec<(u64, u64)>> due to the type of the argument passed
--> src/track.rs:157:13
|
157 | Ok(tracks)
| ^^^------^
| |
| this argument influences the type of Ok
- Assistant
The error you're encountering is a type mismatch: the function expects to return a
HashMap<String, HashSet<(u64, u64)>>, but you're trying to return aHashMap<String, Vec<(u64, u64)>>. This conflict arises from the difference in how these two collections handle their elements: aHashSetensures that all elements are unique, whereas aVecallows for duplicate elements.Given this information, you need to convert your
HashMap<String, Vec<(u64, u64)>>into the expectedHashMap<String, HashSet<(u64, u64)>>. Here's how you can do this transformation: