From: Ralf Jung Date: Fri, 28 Apr 2023 13:35:11 +0000 (+0200) Subject: Merge pull request #40 from bzindovic/bzindovic-part06-typo-fix X-Git-Url: https://git.ralfj.de/rust-101.git/commitdiff_plain/de20ea2de7cb19c2c379fcd61279e13da9c8193d?hp=9960465b9f5be770af699b69e4ebd580d8e6a3e4 Merge pull request #40 from bzindovic/bzindovic-part06-typo-fix Fix a typo in part 6 --- diff --git a/src/part06.rs b/src/part06.rs index 939fe08..4c7ee24 100644 --- a/src/part06.rs +++ b/src/part06.rs @@ -127,8 +127,8 @@ fn head(v: &Vec) -> Option<&T> { //@ have aliasing (of `first` and `v`) and mutation. But this time, the bug is hidden behind the //@ call to `head`. How does Rust solve this? If we translate the code above to Rust, it doesn't //@ compile, so clearly we are good - but how and why? -//@ (Notice that have to explicitly assert using //@ `unwrap` that `first` is not `None`, whereas -//@ the C++ code above would silently dereference a //@ `NULL`-pointer. But that's another point.) +//@ (Notice that we use `unwrap` to explicitly assert that `first` is not `None`, whereas +//@ the C++ code above would silently dereference a `NULL`-pointer. But that's another point.) fn rust_foo(mut v: Vec) -> i32 { let first: Option<&i32> = head(&v); /* v.push(42); */