]> git.lizzy.rs Git - rust.git/commit - src/librustc_llvm/build.rs
Rollup merge of #74021 - 1011X:master, r=dtolnay
authorManish Goregaokar <manishsmail@gmail.com>
Sat, 18 Jul 2020 23:50:54 +0000 (16:50 -0700)
committerGitHub <noreply@github.com>
Sat, 18 Jul 2020 23:50:54 +0000 (16:50 -0700)
commitf305b200df5af87608677f30c272f47cf2210623
treec476911c7e60d8128ebd76eb49651c2c875000a0
parenta6266e2d606802b8e9e326dee6410f914959e546
parent30b8835d1d0f531aa1d5875cde5ffae347177fd3
Rollup merge of #74021 - 1011X:master, r=dtolnay

impl Index<RangeFrom> for CStr

This change implements (partial) slicing for `CStr`.

Since a `CStr` must end in a null byte, it's not possible to trim from the right and still have a valid `CStr`. But, it *is* possible to trim from the left. This lets us be a bit more flexible and treat them more like strings.

```rust
let string = CStr::from_bytes_with_nul(b"Hello World!\0");
let result = CStr::from_bytes_with_nul(b"World!\0");
assert_eq!(&string[6..], result);
```