-
Notifications
You must be signed in to change notification settings - Fork 807
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
Support shrink to empty #6817
Support shrink to empty #6817
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -468,7 +468,7 @@ impl MutableBuffer { | |
} | ||
|
||
#[inline] | ||
fn dangling_ptr() -> NonNull<u8> { | ||
pub(crate) fn dangling_ptr() -> NonNull<u8> { | ||
// SAFETY: ALIGNMENT is a non-zero usize which is then casted | ||
// to a *mut T. Therefore, `ptr` is not null and the conditions for | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not introduced in this PR, but this function isn't generic, so I am not sure what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a copy-pasta from |
||
// calling new_unchecked() are respected. | ||
|
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.
I suggest adding some some comments about this function given its name.
Specifically, that it returns a valid, u8 pointer that is valid for the entire life of the process. Suitable for allocations of 0 length.
I realize it wasn't introduced in this PR, but the name is confusing to me -- Maybe calling it
arbtrary_ptr()
or something would be less confusing 🤔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.
Yeah dangling is an odd name, but is based on what the standard library calls it. I have added some docs to this effect