1
Fork 0

Auto merge of #118484 - blyxxyz:os-str-slice, r=BurntSushi

Add substring API for `OsStr`

This adds a method for taking a substring of an `OsStr`, which in combination with [`OsStr::as_encoded_bytes()`](https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.as_encoded_bytes) makes it possible to implement most string operations in safe code.

API:
```rust
impl OsStr {
    pub fn slice_encoded_bytes<R: ops::RangeBounds<usize>>(&self, range: R) -> &Self;
}
```
Motivation, examples and research at https://github.com/rust-lang/libs-team/issues/306.

Tracking issue: #118485

cc `@epage`
r? libs-api
This commit is contained in:
bors 2023-12-02 20:02:15 +00:00
commit d5fab33766
3 changed files with 131 additions and 2 deletions

View file

@ -341,6 +341,7 @@
#![feature(round_ties_even)]
#![feature(slice_internals)]
#![feature(slice_ptr_get)]
#![feature(slice_range)]
#![feature(std_internals)]
#![feature(str_internals)]
#![feature(strict_provenance)]