Repository navigation
[gridstore, UIO] Simplify OptionalPointer - #8945
Conversation
generall
left a comment
There was a problem hiding this comment.
As @xzfc mentioned here #8953 (comment)
we unfortunately can't do bytemuck that simple
|
Depends on #8955 |
…8953) Drop the `+ UniversalRead<OptionalPointer>` / `+ UniversalWrite<OptionalPointer>` trait bounds added in the previous two commits. Reads and writes of `OptionalPointer` and `TrackerHeader` now go through `bytemuck::from_bytes` / `bytemuck::bytes_of` on the existing `u8` byte slices instead. This keeps the unsafe-transmute removal but avoids the turbofish noise (`UniversalWrite::<u8>::flusher(&self.storage)`, `<S as UniversalRead<u8>>::open`, …) that two `T`s on `S` forced everywhere. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
d979396 to
20a8a10
Compare
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis change replaces the generic Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
* derive bytemuck::Pod on `OptionalPointer`, get rid of legacy transmute * remove one layer of Option in `get_raw` * keep `UniversalRead<u8>` bound, do bytemuck conversion at call site (#8953) Drop the `+ UniversalRead<OptionalPointer>` / `+ UniversalWrite<OptionalPointer>` trait bounds added in the previous two commits. Reads and writes of `OptionalPointer` and `TrackerHeader` now go through `bytemuck::from_bytes` / `bytemuck::bytes_of` on the existing `u8` byte slices instead. This keeps the unsafe-transmute removal but avoids the turbofish noise (`UniversalWrite::<u8>::flusher(&self.storage)`, `<S as UniversalRead<u8>>::open`, …) that two `T`s on `S` forced everywhere. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> * extra refactoring after #8955 * explicit zeroed instantiation --------- Co-authored-by: Andrey Vasnetsov <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
The type for interacting with optional stored pointers was
Optional<ValuePointer>. But since generics can't derivebytemuck::Podcleanly, handling this type required reading[u8]from storage, and then transmuting.This PR simplifies implementation by making the optional type concrete:
OptionalPointer. This lets the storage backend do the cast via bytemuck, and gets rid of the "legacy code" lint suppression.Additionally, removes one layer of option from
get_raw:Result<Option<Option<ValuePointer>>>toResult<Option<ValuePointer>>