Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Revisit iteration styles #4

Open
fpacifici opened this issue Apr 21, 2022 · 0 comments
Open

Revisit iteration styles #4

fpacifici opened this issue Apr 21, 2022 · 0 comments

Comments

@fpacifici
Copy link
Collaborator

Reflect on the different iteration styles into_iter, iter, iter_mut, vs &, &mut.
for example here:

for topic in topics.iter() {

you take the argument as an allocated Vec, but you only iterate over references of its members via .iter, afterwards freeing that allocation. Better to either take a &[T] as above, or consume the vector via into_iter (or just … in topics as that will also consume the vec)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant