*Map::iter_cloned & *Map::iter_copied

For everything below, cloned could also be 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?

You can do 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.