Medium
An explicit drop() call vs. end-of-scope destruction order
What does this program print?
main.rs
struct Resource(&'static str);
impl Drop for Resource {
fn drop(&mut self) {
println!("Dropping {}", self.0);
}
}
fn main() {
let a = Resource("a");
let b = Resource("b");
let c = Resource("c");
println!("Created {}, {}, {}", a.0, b.0, c.0);
drop(b);
println!("End of main");
}15 of 53 in Rust