-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
allocator: refactor for stabilisation #157428
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
base: main
Are you sure you want to change the base?
Changes from all commits
354678d
ecfda4e
565c994
d82182c
a3db8cd
0fca0d1
d4cb394
24f496f
4868441
ad88f59
5af9c06
c172f93
dffda9e
aa9abd6
59219ba
4805e24
ffdb858
0c2cf06
c2908f6
c4ac24b
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 |
|---|---|---|
|
|
@@ -896,6 +896,22 @@ pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box<str> { | |
| unsafe { Box::from_raw(Box::into_raw(v) as *mut str) } | ||
| } | ||
|
|
||
| /// Converts a boxed slice of bytes to a boxed string slice without checking | ||
| /// that the string contains valid UTF-8 generically over the box's allocator. | ||
| /// | ||
| /// # Safety | ||
| /// | ||
| /// * The provided bytes must contain a valid UTF-8 sequence. | ||
| #[unstable(feature = "allocator_api", issue = "32838")] | ||
| #[must_use] | ||
| #[inline] | ||
| pub unsafe fn from_boxed_utf8_unchecked_in<A: crate::alloc::Allocator>( | ||
|
Contributor
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 to nitpick too strongly but generally I would expect the
Member
Author
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 don't mind changing the name or even making this private. i just needed the method for that one conversion /shrug |
||
| v: Box<[u8], A>, | ||
| ) -> Box<str, A> { | ||
| let (ptr, alloc) = Box::into_raw_with_allocator(v); | ||
| unsafe { Box::from_raw_in(ptr as *mut str, alloc) } | ||
| } | ||
|
|
||
| /// Converts leading ascii bytes in `s` by calling the `convert` function. | ||
| /// | ||
| /// For better average performance, this happens in chunks of `2*size_of::<usize>()`. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.