diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-10-01 20:31:54 +0200 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-10-01 20:48:52 +0200 |
| commit | 2b944d0c38ebfb99252ccfcb6200db28a217ee07 (patch) | |
| tree | 83104e22bfddbca846709dc336c223869006cbf2 /src | |
| parent | 169ef781f9ddc9954a2e1aa58351cd14983c9ae6 (diff) | |
| download | rust-2b944d0c38ebfb99252ccfcb6200db28a217ee07.tar.gz rust-2b944d0c38ebfb99252ccfcb6200db28a217ee07.zip | |
Fix example
Diffstat (limited to 'src')
| -rw-r--r-- | src/docs/as_ptr_cast_mut.txt | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/docs/as_ptr_cast_mut.txt b/src/docs/as_ptr_cast_mut.txt index 83332a2559d..228dde996bb 100644 --- a/src/docs/as_ptr_cast_mut.txt +++ b/src/docs/as_ptr_cast_mut.txt @@ -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) }; ``` \ No newline at end of file |
