-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add safety documentation #2344
base: main
Are you sure you want to change the base?
Add safety documentation #2344
Conversation
I guess the part where we say "pointer is required to be non-null can be covered by simply utilizing the |
/// | ||
/// This function requires the following invariants to be upheld: | ||
/// - `capacity` is smaller or equal to `length` | ||
/// - The number of bytes allocated by the pointer must be equal to `capacity` |
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.
This one is only the case for Region<Owned>
, right? Because a slice does not uphold this.
/// - `capacity` is smaller or equal to `length` | ||
/// - The number of bytes allocated by the pointer must be equal to `capacity` | ||
/// - The byte range covered by `length` must be initialized | ||
/// - `ptr` is a non-dangling and non-null pointer |
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.
What do we need the non-dangling part for? I'm pretty sure vec![].as_ptr()
creates a dangling pointer
Co-authored-by: Christoph Otter <[email protected]>
That sounds nice. I'm always a fan of enforcing correct usage through the type system where possible. |
Co-authored-by: Christoph Otter <[email protected]>
Closes #2305
I hope this documentation makes it a little clearer why the usage here is sound.
Best proof-read by someone that isn't me to make sure what I wrote is actually coherent for others.