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

Use newtypes for the arena types #175

Merged
merged 6 commits into from
May 12, 2024
Merged

Use newtypes for the arena types #175

merged 6 commits into from
May 12, 2024

Conversation

sampsyo
Copy link
Collaborator

@sampsyo sampsyo commented May 12, 2024

Our little homegrown arena library, called pool, is a little like id-arena or similar, but with special stuff we need for our "zero-copy" use case.

Previously, it was implemented as special traits that extend plain old Rust types like &[T] and Vec<T>. This was convenient in some ways but got confusing and prevented some fancier convenience features. I've now wrapped these in newtypes Store and Pool that let us more carefully control the interface to the arenas. This should be less error-prone in the long run. As an added bonus, it makes it easier to access pools with subscripting: for example, gfa.segs[id] works where id has type Id<Segment>.

sampsyo added 6 commits May 11, 2024 16:32
These are now stores, not pools, so simpler names make sense.
Now it's not just a slice. Is this a good idea?
More idiomatic Rust.
Now we can do, like, `segs[id]` instead of `segs.get_id(id)`. Nice!
They are now very easy to express with subscripting.
@sampsyo sampsyo merged commit a03db8c into main May 12, 2024
6 checks passed
@sampsyo sampsyo deleted the pool-newtype branch May 12, 2024 00:24
sampsyo added a commit that referenced this pull request Dec 29, 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

Successfully merging this pull request may close these issues.

1 participant