fork download
  1. fn main() {
  2. let mut a = Vec::new();
  3. let b = &a;
  4. a.push(1);
  5. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.rs:4:5: 4:6 error: cannot borrow `a` as mutable because it is also borrowed as immutable
prog.rs:4     a.push(1);
              ^
prog.rs:3:14: 3:15 note: previous borrow of `a` occurs here; the immutable borrow prevents subsequent moves or mutable borrows of `a` until the borrow ends
prog.rs:3     let b = &a;
                       ^
prog.rs:5:2: 5:2 note: previous borrow ends here
prog.rs:1 fn main() {
prog.rs:2     let mut a = Vec::new();
prog.rs:3     let b = &a;
prog.rs:4     a.push(1);
prog.rs:5 }
          ^
error: aborting due to previous error
stdout
Standard output is empty