Typically these days I like to use x.cast::<Y>() instead of x as *const Y to perform pointer casting (and in many contexts it's also convenient to let type inference work on just x.cast(), which reads a lot nicer than x as *const _). It also avoids const <-> mut casting by accident.
I just discovered ptr::from_ref and am now similarly excited to replace &x as *const X with ptr_from_ref(&x).
... so this PR is just a few tidy-ups across the codebase!
Typically these days I like to use
x.cast::<Y>()
instead ofx as *const Y
to perform pointer casting (and in many contexts it's also convenient to let type inference work on justx.cast()
, which reads a lot nicer thanx as *const _
). It also avoids const <-> mut casting by accident.I just discovered
ptr::from_ref
and am now similarly excited to replace&x as *const X
withptr_from_ref(&x)
.... so this PR is just a few tidy-ups across the codebase!