-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 str pointer methods #85816
Add str pointer methods #85816
Conversation
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
I'm unsure about |
@jfager I would expect that |
@WaffleLapkin looks like you tagged the wrong person! |
Oops, right. I've meant to tag @jfrimmel 😅 |
The The But I'm not sure about the |
@m-ou-se my original motivation for
Then maybe instead of Not sure which way is better. |
@WaffleLapkin Ping from triage, what's next steps here? |
Yeah maybe. I'd still put that in cc @rust-lang/libs-api Any thoughts on these functions? |
I don't see why the safety requirement of get_unchecked involves utf8 boundaries. I would expect only the same safety requirements as https://doc.rust-lang.org/std/primitive.pointer.html#method.add. Please document safety requirements in a Can we have safe indexing that works like https://doc.rust-lang.org/std/primitive.pointer.html#method.wrapping_add ? |
Hm. So |
So, to summarize the state of this PR.
I'm waiting for the decision on |
☔ The latest upstream changes (presumably #85769) made this pull request unmergeable. Please resolve the merge conflicts. |
Triage: Still has conflicts |
3a74406
to
7425507
Compare
☔ The latest upstream changes (presumably #86808) made this pull request unmergeable. Please resolve the merge conflicts. |
7425507
to
55646f0
Compare
☔ The latest upstream changes (presumably #87875) made this pull request unmergeable. Please resolve the merge conflicts. |
The functions are under feature gate `str_from_raw_parts` and are similar to `slice_from_raw_parts`, `slice_from_raw_parts_mut`.
55646f0
to
4c8427c
Compare
This comment has been minimized.
This comment has been minimized.
These items allow to make inherent impls for `*const str` and `*mut str`.
This patch adds the following methods to `*const str` and `*mut str`: - `len` - `as_ptr` (`as_mut_ptr`) - `get_unchecked` (`get_unchecked_mut`) Similar methods have already existed for raw slices.
This patch adds the following methods to `NonNull<str>`: - `str_from_raw_parts` - `len` - `as_non_null_ptr` - `as_mut_ptr` - `get_unchecked_mut` Similar methods have already existed for raw slices, raw strings and nonnull raw strings.
4c8427c
to
3ebb712
Compare
☔ The latest upstream changes (presumably #91203) made this pull request unmergeable. Please resolve the merge conflicts. |
This PR adds the following functions for pointers to
str
, similar to already existing functions for pointers to[T]
.I wasn't sure about feature gates and how to group them, so the advice is very appreciated.
This PR also adds
const_str_ptr
andmut_str_ptr
lang items (they are required for*const str
and*mut str
impls).See also:
len
for raw slices -- Tracking Issue for raw slice len() method (slice_ptr_len, const_slice_ptr_len) #71146as{,_mut,_non_null}_ptr
,get_unchecked[_mut]
-- Tracking Issue for raw slice getters (slice_ptr_get) #74265ptr::slice_from_raw_parts[_mut]
-- Tracking issue forptr::slice_from_raw_parts[_mut]
#36925