X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/98765a4ec4731843578d0631f5a10b5d876549f2..bfcb8f515cc956fca8d44e76d2ecb33d3de591fe:/src/part05.rs?ds=inline diff --git a/src/part05.rs b/src/part05.rs index 8a2cd90..49e57db 100644 --- a/src/part05.rs +++ b/src/part05.rs @@ -47,11 +47,11 @@ impl BigInt { } } - // We can convert any vector of digits into a number, by removing trailing zeros. The `mut` - // declaration for `v` here is just like the one in `let mut ...`: We completely own `v`, but Rust - // still asks us to make our intention of modifying it explicit. This `mut` is *not* part of the - // type of `from_vec` - the caller has to give up ownership of `v` anyway, so they don't care anymore - // what you do to it. + // We can convert any little-endian vector of digits (i.e., least-significant digit first) into a number, + // by removing trailing zeros. The `mut` declaration for `v` here is just like the one in `let mut ...`: + // We completely own `v`, but Rust still asks us to make our intention of modifying it explicit. This + // `mut` is *not* part of the type of `from_vec` - the caller has to give up ownership of `v` anyway, so + // they don't care anymore what you do to it. // // **Exercise 05.1**: Implement this function. // @@ -147,4 +147,4 @@ fn work_on_variant(mut var: Variant, text: String) { //@ I hope this example clarifies why Rust has to rule out mutation in the presence of aliasing *in general*, //@ not just for the specific case of a buffer being reallocated, and old pointers becoming hence invalid. -//@ [index](main.html) | [previous](part04.html) | [raw source](https://www.ralfj.de/git/rust-101.git/blob_plain/HEAD:/workspace/src/part05.rs) | [next](part06.html) +//@ [index](main.html) | [previous](part04.html) | [raw source](workspace/src/part05.rs) | [next](part06.html)