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

Consider adding CellWriter, CellReader ZSTs #1

Open
71 opened this issue Jul 22, 2023 · 0 comments
Open

Consider adding CellWriter, CellReader ZSTs #1

71 opened this issue Jul 22, 2023 · 0 comments

Comments

@71
Copy link
Owner

71 commented Jul 22, 2023

Consider adding:

  • struct CellWriter<'a, F: Family>(PhantomData<&'a mut ()>)
  • struct CellReader<'a, F: Family>(PhantomData<&'a ()>)

The former defines mutation functions, as well as borrow_mut(&'b mut self) -> CellWriter<'b, F> and borrow(&'b self) -> CellReader<'a, F>. The latter defines read functions as well and is Copyable. Thanks to their lifetime parameters and a careful assignment of Copy / Send / Sync implementations, they could provide the same guarantees as &mut CellOwner<F> and &CellOwner<F> while being zero-sized.

Though &mut CellOwner / &CellOwner (with CellOwner a ZST) can be well optimized, they are nonetheless not zero-sized, so such a change would make borrowing a CellOwner completely free.

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