Now, I want to see how Box<T>::new(x: T) works when the underlying memory allocator fails to allocate memory.
impl<T> Box<T> {
/// Allocates memory on the heap and then places `x` into it.
///
/// This doesn't actually allocate if `T` is zero-sized.
///
/// # Examples
///
/// ```
/// let five = Box::new(5);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline(always)]
pub fn new(x: T) -> Box<T> {
box x
}
Unfortunately, the source code for function Box<T>::new(x: T) seems to not unveil what happens behind the curtains. I'm not sure where to look to learn how box x works..
The function alloc::alloc::alloc doesn't seem to perform any exception checking for null-pointers..
I'm stuck here, and don't know where else to look for more info
Can anyone give some pointers on where to look for info on how Box<T> works when the underlying memory allocator returns a null pointer?