Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of requests for the example:
# Safety
header and// SAFETY
comments so the docs are a good example of what we'd like people to do.dbg!
inside rustdoc examples isn't particularly useful, especially for a function that's never called. Could you maybe do some simple computation on it and return it, so that it could be called andassert!
ed instead? That way Miri can check that it's not accidentally UB, too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review!
I have added the "safety" comments, please let me know if I should make any changes to the text.
I also changed the function to return a value and added an assert.
I'm not sure if that makes sense, though, since this function would normally be called from C++ or some other FFI language.
Alternatively, I could also provide a more general (and more useful) function:
I have actually used that function in my code: https://github.com/AudioSceneDescriptionFormat/asdfspline-rust/blob/e2608b07e2749caf71e43f23d4592849d27dd450/ffi/src/lib.rs#L59-L89.
However, this is a bit more complicated due to the lifetime annotation, so it might not be appropriate here?