That doesn't seem to be what the compilation error says: mut.rs:10:19: 10:20 error: use of moved value: `a` mut.rs:10 println!("{}",a); ^ note: in expansion of format_args! <std macros>:2:23: 2:77 note: expansion site <std macros>:1:1: 3:2 note: in expansion of println! mut.rs:10:5: 10:22 note: expansion site mut.rs:6:13: 6:14 note: `a` moved here because it has type `&mut int`, which is moved by default (use `ref` to override) mut.rs:6 let b = a;
It isn't intuitive that type-annotating `b` would make this error go away. On Mon, Sep 22, 2014 at 10:54 AM, Steve Klabnik <st...@steveklabnik.com> wrote: > Because you need to make b mutable to change its value. Rust's > variable bindings are immutable by default. > _______________________________________________ > Rust-dev mailing list > Rust-dev@mozilla.org > https://mail.mozilla.org/listinfo/rust-dev >
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev