Skip to content

Instantly share code, notes, and snippets.

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