mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-16 05:58:41 +00:00
Fix example
This commit is contained in:
parent
169ef781f9
commit
2b944d0c38
2 changed files with 4 additions and 4 deletions
|
@ -608,13 +608,13 @@ declare_clippy_lint! {
|
|||
/// ### Example
|
||||
/// ```rust
|
||||
/// let string = String::with_capacity(1);
|
||||
/// let ptr = string.as_ptr() as *mut _;
|
||||
/// let ptr = string.as_ptr() as *mut u8;
|
||||
/// unsafe { ptr.write(4) }; // UNDEFINED BEHAVIOUR
|
||||
/// ```
|
||||
/// Use instead:
|
||||
/// ```rust
|
||||
/// let mut string = String::with_capacity(1);
|
||||
/// let string = string.as_mut_ptr();
|
||||
/// let ptr = string.as_mut_ptr();
|
||||
/// unsafe { ptr.write(4) };
|
||||
/// ```
|
||||
#[clippy::version = "1.66.0"]
|
||||
|
|
|
@ -8,12 +8,12 @@ mutability is used, making it unlikely that having it as a mutable pointer is co
|
|||
### Example
|
||||
```
|
||||
let string = String::with_capacity(1);
|
||||
let ptr = string.as_ptr() as *mut _;
|
||||
let ptr = string.as_ptr() as *mut u8;
|
||||
unsafe { ptr.write(4) }; // UNDEFINED BEHAVIOUR
|
||||
```
|
||||
Use instead:
|
||||
```
|
||||
let mut string = String::with_capacity(1);
|
||||
let string = string.as_mut_ptr();
|
||||
let ptr = string.as_mut_ptr();
|
||||
unsafe { ptr.write(4) };
|
||||
```
|
Loading…
Add table
Reference in a new issue