Conversation
|
Seems like I'll need to use |
1bf7336 to
f7d4d95
Compare
hawkw
left a comment
There was a problem hiding this comment.
This looks great to me, thanks for working on it!
I had one major suggestion, which is that we could avoid the use of NonNull::new_unchecked by using the From<&T> impl for NonNull<T>. The difference is that new_unchecked is unsafe to call, because the pointer may be null, while From<&T> is safe, because &T is never null. In this code, all the uses of new_unchecked are in fact safe, because the raw pointers are always immediately constructed from a never-null &T, so it doesn't actually matter which one we use, but it might be a little nicer to have the additional safety net of making it clear that we are relying on Rust invariants here.
Up to you if you want to take that advice — this code is correct either way.
|
I like all your suggestions and learned about |
|
Okay, I think I applied all your suggestions. I also simplified |
Motivation
Resolves #1073, quoting from there:
Solution
I've made the change to the function signature and let rustc guide me through the process of fixing all callers. This was mostly straightforward but it is
unsafecode so I'm not sure the changes here are correct.