Skip to content

Commit 8f979af

Browse files
committed
Fix UB in as_ptr_cast_mut documentation
1 parent 3b5b2ed commit 8f979af

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clippy_lints/src/casts/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,14 @@ declare_clippy_lint! {
625625
///
626626
/// ### Example
627627
/// ```rust
628-
/// let string = String::with_capacity(1);
629-
/// let ptr = string.as_ptr() as *mut u8;
628+
/// let mut vec = Vec::<u8>::with_capacity(1);
629+
/// let ptr = vec.as_ptr() as *mut u8;
630630
/// unsafe { ptr.write(4) }; // UNDEFINED BEHAVIOUR
631631
/// ```
632632
/// Use instead:
633633
/// ```rust
634-
/// let mut string = String::with_capacity(1);
635-
/// let ptr = string.as_mut_ptr();
634+
/// let mut vec = Vec::<u8>::with_capacity(1);
635+
/// let ptr = vec.as_mut_ptr();
636636
/// unsafe { ptr.write(4) };
637637
/// ```
638638
#[clippy::version = "1.66.0"]

0 commit comments

Comments
 (0)