From 79b6ba1756269ea1c1e588ace17ad26ee954ffc9 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 4 Aug 2017 13:35:59 -0400 Subject: [PATCH 1/2] Casting from a pointer should have type 'isize', not 'i32'. Found via https://github.com/rust-lang/rust/pull/43641. --- second-edition/src/ch19-01-unsafe-rust.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/second-edition/src/ch19-01-unsafe-rust.md b/second-edition/src/ch19-01-unsafe-rust.md index c963e154c4..f3b5e84fcd 100644 --- a/second-edition/src/ch19-01-unsafe-rust.md +++ b/second-edition/src/ch19-01-unsafe-rust.md @@ -100,7 +100,7 @@ There’s not usually a good reason to be writing code like this, but it is possible: ```rust -let address = 0x012345; +let address = 0x012345isize; let r = address as *const i32; ``` @@ -305,7 +305,7 @@ location and creates a slice ten thousand items long: ```rust use std::slice; -let address = 0x012345; +let address = 0x012345isize; let r = address as *mut i32; let slice = unsafe { From 4fd17fde8069be04d957fd99078a2f81faf53d32 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 4 Aug 2017 14:06:33 -0400 Subject: [PATCH 2/2] 'isize' -> 'usize'. --- second-edition/src/ch19-01-unsafe-rust.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/second-edition/src/ch19-01-unsafe-rust.md b/second-edition/src/ch19-01-unsafe-rust.md index f3b5e84fcd..6f02a4998c 100644 --- a/second-edition/src/ch19-01-unsafe-rust.md +++ b/second-edition/src/ch19-01-unsafe-rust.md @@ -100,7 +100,7 @@ There’s not usually a good reason to be writing code like this, but it is possible: ```rust -let address = 0x012345isize; +let address = 0x012345usize; let r = address as *const i32; ``` @@ -305,7 +305,7 @@ location and creates a slice ten thousand items long: ```rust use std::slice; -let address = 0x012345isize; +let address = 0x012345usize; let r = address as *mut i32; let slice = unsafe {