-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
Description
This code prints malloc
twice and free
once:
#![feature(generators, generator_trait)]
use std::ops::Generator;
fn main() {
let mut gen = || {
(NoisyDrop::new(),
yield,
NoisyDrop::new(),
yield
);
};
gen.resume();
gen.resume();
drop(gen);
}
struct NoisyDrop;
impl NoisyDrop {
fn new() -> Self {
println!("malloc");
NoisyDrop
}
}
impl Drop for NoisyDrop {
fn drop(&mut self) {
println!("free");
}
}