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

borrow instead of consume idgenerator #1164

Open
TheNumenorean opened this issue Apr 21, 2018 · 2 comments
Open

borrow instead of consume idgenerator #1164

TheNumenorean opened this issue Apr 21, 2018 · 2 comments

Comments

@TheNumenorean
Copy link

Why does the widget_ids! macros generate the struct to consume the id generator? It seems like it could be just borrowed, and that allows it to be reused for building multipl different id structs, which is good for compartmentalization.

@mitchmindtree
Copy link
Contributor

This is fine with me if it will help to improve ergonomics 👍

Just thought I'd also mention that this probably won't affect performance at all as the widget ID generator is just a very thin wrapper around &mut Ui that acts kind of like an iterator.

One thing I've been considering is changing the generated struct to take a generic type that implements some IntoWidgetIdGenerator trait. This way we could allow the constructor function to take the generator directly or via &mut or even just &mut Ui. I'll likely implement this when I get around to implementing #1165 if noone beats me to it.

@TheNumenorean
Copy link
Author

It would certainly be convenient, but waiting for the overhaul would be sufficient i suspect.

I would submit a pull req, but i am new to Rust and not confident enough yet.

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

No branches or pull requests

3 participants