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

iter_all_tabs and iter_all_nodes should return indexes #249

Open
enomado opened this issue Sep 26, 2024 · 1 comment
Open

iter_all_tabs and iter_all_nodes should return indexes #249

enomado opened this issue Sep 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@enomado
Copy link
Contributor

enomado commented Sep 26, 2024

Current api is like

Iterator<Item = (SurfaceIndex, &Node<Tab>)>

whith is not very practical. better to return

Iterator<Item = (SurfaceIndex, NodeIndex)>

and

Iterator<Item = (SurfaceIndex, NodeIndex, TabIndex)>

Because all operations(focusing) is performed with indexes.

BTW

My case is search to find node by part of it(since Node must have id, find_tab is almost useless), so I was forced to re-create that iterators in my code.

We could actually merge find_tab and iter_all_nodes with "index api"

@enomado enomado added the bug Something isn't working label Sep 26, 2024
@enomado
Copy link
Contributor Author

enomado commented Sep 26, 2024

Currently i use something like

        .iter_all_tabs()
        .find_map(|(loc, itab)| (itab.variant == tab).then_some(loc));
        .iter_all_nodes()
        .enumerate()
        .find_map(|(node_idx, (surface_index, node))| {
            node.iter_tabs().enumerate().find_map(|(tab_index, itab)| {
                (itab.variant == tab).then_some((surface_index, NodeIndex(node_idx), TabIndex(tab_index)))
            })
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant