Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add children_iter_mut() #18

Open
4 tasks
niklasdewally opened this issue Nov 2, 2024 · 0 comments
Open
4 tasks

Add children_iter_mut() #18

niklasdewally opened this issue Nov 2, 2024 · 0 comments

Comments

@niklasdewally
Copy link
Collaborator

niklasdewally commented Nov 2, 2024

Description

A common pattern is to do

let mut children = expr.children();
for child in children.iter_mut() {
  // do some stuff
}
let expr = expr.with_children(children);

It would be nice to do :

for child in expr.iter_mut() {
  // do some stuff
}

In a sense this is just descend(), but it links with the rest of Rust's Iterator API, instead of just being a map.

More generally, we could provide children_iter(), universe_iter(), children_iter_mut(), universe_iter_mut() to turn all the things into iterators.

Questions:

  • Exactly which iter functions do we provide and what do we call them?

  • How should we traverse for universe_iter()? Should this be like transform()?

To-do

  • Implement children_iter(), universe_iter()
  • Implement children_bi_iter(), universe_bi_iter()
  • Implement children_iter_mut(), universe_iter_mut()
  • Implement children_bi_iter_mut(), universe_bi_iter_mut()
@niklasdewally niklasdewally changed the title Add iter_mut Add children_iter_mut() Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant