diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-08-21 16:54:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-21 16:54:06 +0200 |
| commit | fd403f5d1780388a89fc70a3dd8bdac3c0e606c1 (patch) | |
| tree | f2428e478c23d4a0b49cbbd5712eac688dd56d09 /library/alloc/src | |
| parent | bc66f4085aedd6acd02efaae20dcb9cad831be90 (diff) | |
| parent | b2625e24b95b5077a1ec59ad6ac667939eb6521f (diff) | |
| download | rust-fd403f5d1780388a89fc70a3dd8bdac3c0e606c1.tar.gz rust-fd403f5d1780388a89fc70a3dd8bdac3c0e606c1.zip | |
Rollup merge of #100821 - WaffleLapkin:ptr_add_docs, r=scottmcm
Make some docs nicer wrt pointer offsets This PR replaces `pointer::offset` with `pointer::add` and similarly `.cast().wrapping_add().cast()` with `.wrapping_byte_add()` **in docs**. r? ``````@scottmcm`````` _split off from #100746_
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/ffi/c_str.rs | 6 | ||||
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/library/alloc/src/ffi/c_str.rs b/library/alloc/src/ffi/c_str.rs index ae61b1f1e8e..be21d8c722d 100644 --- a/library/alloc/src/ffi/c_str.rs +++ b/library/alloc/src/ffi/c_str.rs @@ -436,9 +436,9 @@ impl CString { /// /// unsafe { /// assert_eq!(b'f', *ptr as u8); - /// assert_eq!(b'o', *ptr.offset(1) as u8); - /// assert_eq!(b'o', *ptr.offset(2) as u8); - /// assert_eq!(b'\0', *ptr.offset(3) as u8); + /// assert_eq!(b'o', *ptr.add(1) as u8); + /// assert_eq!(b'o', *ptr.add(2) as u8); + /// assert_eq!(b'\0', *ptr.add(3) as u8); /// /// // retake pointer to free memory /// let _ = CString::from_raw(ptr); diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index fa9f2131c0c..fe4dcafe14c 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -542,8 +542,8 @@ impl<T> Vec<T> { /// /// unsafe { /// // Overwrite memory with 4, 5, 6 - /// for i in 0..len as isize { - /// ptr::write(p.offset(i), 4 + i); + /// for i in 0..len { + /// ptr::write(p.add(i), 4 + i); /// } /// /// // Put everything back together into a Vec @@ -702,8 +702,8 @@ impl<T, A: Allocator> Vec<T, A> { /// /// unsafe { /// // Overwrite memory with 4, 5, 6 - /// for i in 0..len as isize { - /// ptr::write(p.offset(i), 4 + i); + /// for i in 0..len { + /// ptr::write(p.add(i), 4 + i); /// } /// /// // Put everything back together into a Vec |
