Closed
Description
MWE:
fn get() -> Option<String> {
Some("hi".to_string())
}
fn main() {
let y = match get() {
Some(x) => x.as_slice().clone(),
None => "hello"
};
let mut z = "something".to_string();
for i in range(1,1000u) {
z = format!("{}", i);
println!("{}", z)
}
println!("{}", y)
}
The last thing it prints out should be "hi". Instead it prints out "99" -- it it looks like the String
x is deallocated in the match, but the pointer to the freed memory lives on.