Skip to content

Commit 2b944d0

Browse files
committed
Fix example
1 parent 169ef78 commit 2b944d0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

clippy_lints/src/casts/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,13 @@ declare_clippy_lint! {
608608
/// ### Example
609609
/// ```rust
610610
/// let string = String::with_capacity(1);
611-
/// let ptr = string.as_ptr() as *mut _;
611+
/// let ptr = string.as_ptr() as *mut u8;
612612
/// unsafe { ptr.write(4) }; // UNDEFINED BEHAVIOUR
613613
/// ```
614614
/// Use instead:
615615
/// ```rust
616616
/// let mut string = String::with_capacity(1);
617-
/// let string = string.as_mut_ptr();
617+
/// let ptr = string.as_mut_ptr();
618618
/// unsafe { ptr.write(4) };
619619
/// ```
620620
#[clippy::version = "1.66.0"]

src/docs/as_ptr_cast_mut.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ mutability is used, making it unlikely that having it as a mutable pointer is co
88
### Example
99
```
1010
let string = String::with_capacity(1);
11-
let ptr = string.as_ptr() as *mut _;
11+
let ptr = string.as_ptr() as *mut u8;
1212
unsafe { ptr.write(4) }; // UNDEFINED BEHAVIOUR
1313
```
1414
Use instead:
1515
```
1616
let mut string = String::with_capacity(1);
17-
let string = string.as_mut_ptr();
17+
let ptr = string.as_mut_ptr();
1818
unsafe { ptr.write(4) };
1919
```

0 commit comments

Comments
 (0)