mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 00:53:31 +00:00
Fix UB in as_ptr_cast_mut
documentation
This commit is contained in:
parent
3b5b2ed01a
commit
8f979af3d1
1 changed files with 4 additions and 4 deletions
|
@ -625,14 +625,14 @@ declare_clippy_lint! {
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// let string = String::with_capacity(1);
|
/// let mut vec = Vec::<u8>::with_capacity(1);
|
||||||
/// let ptr = string.as_ptr() as *mut u8;
|
/// let ptr = vec.as_ptr() as *mut u8;
|
||||||
/// unsafe { ptr.write(4) }; // UNDEFINED BEHAVIOUR
|
/// unsafe { ptr.write(4) }; // UNDEFINED BEHAVIOUR
|
||||||
/// ```
|
/// ```
|
||||||
/// Use instead:
|
/// Use instead:
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// let mut string = String::with_capacity(1);
|
/// let mut vec = Vec::<u8>::with_capacity(1);
|
||||||
/// let ptr = string.as_mut_ptr();
|
/// let ptr = vec.as_mut_ptr();
|
||||||
/// unsafe { ptr.write(4) };
|
/// unsafe { ptr.write(4) };
|
||||||
/// ```
|
/// ```
|
||||||
#[clippy::version = "1.66.0"]
|
#[clippy::version = "1.66.0"]
|
||||||
|
|
Loading…
Reference in a new issue