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
[FEATURE] Detect name collisions #693
Comments
Digging into the API further, it seems that being able to name multiple views identically is an intended feature. Then perhaps it would be best to allow opting out of this feature through a separate unique identifier mechanism ? |
Hi, and thanks for the report! I'm not entirely sure how to make the API for this ergonomic.
I suspect a better debugging experience may also help fix issues early in development where the same name is used twice by mistake. Maybe reporting when multiple views exist for a given name? |
I agree that reporting duplicate names could be sufficient, the tricky part is to find the right communication channel to do so:
So maybe an INFO log, or alternatively returning the number of duplicates from with_name/the NamedView constructor could also work (think (Self, usize) tuple). I'm also not terribly convinced by my previous Result & fallback ideas. A bit of documentation on with_name/NamedView that warns about duplicate names being supported could also be useful. If you added a unique name generator, something like... let (named_view, name): (NamedView, Rc<str>) = inner_view.with_unique_name(); ...I would personally use that, but it would probably be a good idea to gauge wider interest if you have a way to poll other cursive users. |
Is your feature request related to a problem? Please describe.
At this point in time, cursive does not detect when multiple views are given the same name. Puzzling debugging sessions may ensue as call_on_name calls reach the wrong target.
Describe the solution you'd like
Cursive should detect this API usage error and handle it. Panicking would most likely be appropriate here.
Describe alternatives you've considered
However, I think this is too much of an edge case to justify expending so much implementation care and/or API surface on it.
The text was updated successfully, but these errors were encountered: