Fix UB in as_ptr_cast_mut
documentation
This commit is contained in:
parent
3b5b2ed01a
commit
8f979af3d1
@ -625,14 +625,14 @@
|
||||
///
|
||||
/// ### Example
|
||||
/// ```rust
|
||||
/// let string = String::with_capacity(1);
|
||||
/// let ptr = string.as_ptr() as *mut u8;
|
||||
/// let mut vec = Vec::<u8>::with_capacity(1);
|
||||
/// let ptr = vec.as_ptr() as *mut u8;
|
||||
/// unsafe { ptr.write(4) }; // UNDEFINED BEHAVIOUR
|
||||
/// ```
|
||||
/// Use instead:
|
||||
/// ```rust
|
||||
/// let mut string = String::with_capacity(1);
|
||||
/// let ptr = string.as_mut_ptr();
|
||||
/// let mut vec = Vec::<u8>::with_capacity(1);
|
||||
/// let ptr = vec.as_mut_ptr();
|
||||
/// unsafe { ptr.write(4) };
|
||||
/// ```
|
||||
#[clippy::version = "1.66.0"]
|
||||
|
Loading…
Reference in New Issue
Block a user