mupdf-rs
mupdf-rs copied to clipboard
Improve `unsafe` comments/documentation/encapsulation
As I've been poking through the code of this library recently, I've noticed that there are a lot of undocumented unsafe fns and blocks. I'd like to go through and improve documentation and encapsulation for a lot of these areas, if that's alright.
The specific steps that I feel could help with this a lot:
- Apply the
unsafe_op_in_unsafe_fn,clippy::multiple_unsafe_ops_per_block, andclippy::undocumented_unsafe_blockslints in the Cargo.toml (and fix what they warn) - Replace a lot of the
inner: *mut _fields withinner: NonNull<_>instead to ensure the inner ptrs aren't null when we dereference them - Add utility fns that utilize
NonNull::as_refto get valid references toinner(for a lot of these wrapping structs) to avoid needing an unsafe block per-function
Do these all sound like reasonable steps? Would you accept PRs that take these steps?