Open mahkoh opened 8 years ago
This is mostly useful for convenience methods because you cannot recover from allocation failure. Something like this:
impl Place<T> for BoxBuf<T, H> { where H: alloc::Allocator, H::Pool: Default, { fn pointer(&mut self) -> *mut T { /* ... */ } } impl<T, H> Boxed<T> for Box<T, H> where H: alloc::Allocator, H::Pool: Default, { type Data = T; type Place = BoxBuf<T, H>; unsafe fn finalize(filled: BoxBuf<T, H>) -> Box<T, H> { /* ... */ } } impl<T, H> BoxPlace<T> for BoxBuf<T, H> where H: alloc::Allocator, H::Pool: Default, { fn make_place() -> BoxBuf<T, H> { Box::new().unwrap() } }
This is mostly useful for convenience methods because you cannot recover from allocation failure. Something like this: