diff options
| author | Ralf Jung <post@ralfj.de> | 2019-05-01 17:59:48 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-05-01 17:59:48 +0200 |
| commit | 1e47250540bc97f921d1b7e2982f1904fa191dff (patch) | |
| tree | 30c0e7841d8190f846c568f6bf44ca83ae75f70e /src/libcore/slice | |
| parent | 6cc24f26036b28fb3366de86efe3da6c4464057a (diff) | |
as_ptr returns a read-only pointer
Diffstat (limited to 'src/libcore/slice')
| -rw-r--r-- | src/libcore/slice/mod.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 8731f486753..c273153fa5e 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -359,6 +359,10 @@ impl<T> [T] { /// The caller must ensure that the slice outlives the pointer this /// function returns, or else it will end up pointing to garbage. /// + /// The caller must also ensure that the memory the pointer (non-transitively) points to + /// is never written to (except inside an `UnsafeCell`). If you need to mutate + /// the contents of the slice, use [`as_mut_ptr`]. + /// /// Modifying the container referenced by this slice may cause its buffer /// to be reallocated, which would also make any pointers to it invalid. /// @@ -374,6 +378,8 @@ impl<T> [T] { /// } /// } /// ``` + /// + /// [`as_mut_ptr`]: #method.as_mut_ptr #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub const fn as_ptr(&self) -> *const T { |
