This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::cell::UnsafeCell; | |
struct Pool(usize); | |
impl Pool { | |
fn new(&mut self) -> Box<Data> { | |
// record which pool `data` came from. | |
Box::new(Data(self.0)) | |
} | |
fn free(&mut self, data: Box<Data>) { | |
// enfore that `data` wwas allocated from this pool |