void foo() {
int i;
System.out.println("" + i); // uninitialized variable
}
fn foo() {
let i: u32;
println!("{}", i); // error
let v: Vec<u32> = vec![];
drop(v); // moved out of `v` -- "deinitialization"
println!("{:?}", v); // error
let tuple: (Vec<u32>, Vec<u32>) = (vec![], vec![]);
drop(tuple.0); // moved out of `v` -- "deinitialization"
println!("{:?}", tuple.0); // error
println!("{:?}", tuple.1); // OK
struct Bar { v: Vec<u32> }
impl Drop for Bar { }
let tuple: &Vec<u32> = ...;
drop(*tuple); // error
let b: Bar = Bar { v: vec![] };
drop(b.v); // error
let b: [Bar; 2] = ...;
drop(b[0]); // error
fn far() {
void foo() {
int i;
System.out.println("" + i); // uninitialized variable
}
fn foo() {
let i: u32;
println!("{}", i); // error
}
fn foo() {
let v: Vec<u32> = vec![];
drop(v); // moved out of `v` -- "deinitialization"
println!("{:?}", v); // error
}
fn foo() {
let tuple: (Vec<u32>, Vec<u32>) = (vec![], vec![]);
drop(tuple.0); // moved out of `v` -- "deinitialization"
println!("{:?}", tuple.0); // error
println!("{:?}", tuple.1); // OK
}
struct Bar { v: Vec<u32> }
impl Drop for Bar { }
fn foo() {
let tuple: &Vec<u32> = ...;
drop(*tuple); // error
let b: Bar = Bar { v: vec![] };
drop(b.v); // error
let b: [Bar; 2] = ...;
drop(b[0]); // error
}
Dynamic drop
fn far() {