Is a Box allocation stable?
The Rust Programming Language Forum
Is a Box allocation stable?
Is this code safe? If not, how to fix? I'd also appreciate pointers to appropriate documentation describing why this is safe (or not), the documentation of Box is somewhat sparse in this regard. use std::cell::Cell; struct Storage { boxes: Cell<Vec<std::boxed::Box<[u8]>>>, } impl Storage { fn new() -> Storage { Storage { boxes: Cell::new(vec![]) } } fn add<'x>(&'x self, data: &[u8]) -> &'x [u8] { let mut boxes = self.boxes.take(); boxes.push(data.to_vec().into_boxed...
0 comments
No comments yet.