]> git.lizzy.rs Git - rust.git/commit - src/tools/clippy
Rollup merge of #60443 - RalfJung:as_ptr, r=SimonSapin
authorMazdak Farrokhzad <twingoow@gmail.com>
Tue, 14 May 2019 20:00:11 +0000 (22:00 +0200)
committerGitHub <noreply@github.com>
Tue, 14 May 2019 20:00:11 +0000 (22:00 +0200)
commit088c99410b8516a4fc639507ab6c27184875d005
tree5a1504b709a8d88764f0601b9c4b4b198ee800d3
parentbab03cecfeadcbc79ee2aead61c4de973e5649a0
parent30cf0e4251533e67603c755acee5b0bd56197fce
Rollup merge of #60443 - RalfJung:as_ptr, r=SimonSapin

as_ptr returns a read-only pointer

Add comments to `as_ptr` methods to warn that these are read-only pointers, and writing to them is UB.

[It was pointed out](https://internals.rust-lang.org/t/as-ptr-vs-as-mut-ptr/9940) that `CStr` does not even have an `as_mut_ptr`. I originally was going to add one, but there is no method at all that would mutate a `CStr`. Was that a deliberate choice or should I add an `as_mut_ptr` (similar to [what I did for `str`](https://github.com/rust-lang/rust/pull/58200))?
src/libcore/slice/mod.rs
src/libcore/str/mod.rs