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

Debug output of Vec should show gaps #13

Open
clarfonthey opened this issue Sep 22, 2024 · 0 comments
Open

Debug output of Vec should show gaps #13

clarfonthey opened this issue Sep 22, 2024 · 0 comments

Comments

@clarfonthey
Copy link
Contributor

Just to track this so it doesn't get lost.

Was looking into this and it appears a bit more complicated than initially thought. A few thoughts on what would help enable this.

First, there should probably be some sort of "entry API" in the sense of some opaque Entry<'_, T> type that represents a spot in the vec. Essentially, as long as the index of the entry is in-bounds, the entry would be returned, but you can't actually get a reference to the underlying element until it's ready. It should have at least a "try access" method that returns Option<&T>.

Second, there should be an iterator that returns these entries in the correct order. Reading the code for iter, I know that gaps are allowed, but it appears that they're also allowed to be returned out-of-order. This would allow stuff like enumerate() to work properly without having to track indices separately.

Third, we could easily use this new iterator for Debug to display gaps based upon the "try access" method.

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