X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/ab7f9b241429bd675b437d2437799de75d2f409b..940a573f598530dda50c88dabf84e73ff7c73dc5:/src/part06.rs?ds=sidebyside diff --git a/src/part06.rs b/src/part06.rs index 4c0e6ce..7113094 100644 --- a/src/part06.rs +++ b/src/part06.rs @@ -44,7 +44,7 @@ fn vec_min(v: &Vec) -> Option { //@ The answer is already hidden in the type of `vec_min`: `v` is just borrowed, but //@ the Option that it returns is *owned*. We can't just return one of the elements of `v`, //@ as that would mean that it is no longer in the vector! In our code, this comes up when we update -//@ the intermediate variable `min`, which also has type `Option`. If you replace get rid of the +//@ the intermediate variable `min`, which also has type `Option`. If you get rid of the //@ `e.clone()`, Rust will complain "Cannot move out of borrowed content". That's because //@ `e` is a `&BigInt`. Assigning `min = Some(*e)` works just like a function call: Ownership of the //@ underlying data is transferred from `e` to `min`. But that's not allowed, since