For everything below, cloned could also be copied.
cloned
copied
You can't use Iterator::cloned with the iterators from maps because their items are (&K, &V) rather than &Something. Could we add iter_cloned to HashMap and BTreeMap for this use-case?
Iterator::cloned
(&K, &V)
&Something
iter_cloned
HashMap
BTreeMap
You can do hashmap.iter().map(|(k, v)| (k.clone(), v.clone())).
hashmap.iter().map(|(k, v)| (k.clone(), v.clone()))
Yes this is a convenience function that resolves to that, similar to how copied and cloned are convenience functions.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.