Closed briansmith closed 4 months ago
I updated this with the following changes:
Use polyfills for core::ptr::{from_ref, from_mut}
instead of the unnecessary casts we were using before. My overall goal with this series of PRs is to remove all as
casts in favor of safer alternatives, as much as practical. I agree that the implicit coersion, though safer than a cast, is unfortunate because it requires a separate statement. Using from_ref
/from_mut
alleviates this tension.
Undo all the changes to the safety comments. I appreciate the suggestions on how to improve the safety comments I tried to write. Ultimately I think less is more here. What really matters regarding the safety of these functions is the validity of the type coersions and casts. "Proper" safety comments just completely obfuscate this and distract the reader from focusing on the correctness of the type conversions.
Reduce the scope of the
unsafe
blocks to the unsafe operations.