@@ -267,10 +267,11 @@ impl<T, A: AllocRef> Box<T, A> {
267
267
///
268
268
/// ```
269
269
/// #![feature(allocator_api)]
270
+ /// #![feature(new_uninit)]
270
271
///
271
272
/// use std::alloc::System;
272
273
///
273
- /// let mut five = Box::<u32>::new_uninit_in(System);
274
+ /// let mut five = Box::<u32, _ >::new_uninit_in(System);
274
275
///
275
276
/// let five = unsafe {
276
277
/// // Deferred initialization:
@@ -302,10 +303,11 @@ impl<T, A: AllocRef> Box<T, A> {
302
303
///
303
304
/// ```
304
305
/// #![feature(allocator_api)]
306
+ /// #![feature(new_uninit)]
305
307
///
306
308
/// use std::alloc::System;
307
309
///
308
- /// let zero = Box::<u32>::new_zeroed_in(System);
310
+ /// let zero = Box::<u32, _ >::new_zeroed_in(System);
309
311
/// let zero = unsafe { zero.assume_init() };
310
312
///
311
313
/// assert_eq!(*zero, 0)
@@ -520,13 +522,16 @@ impl<T: ?Sized, A: AllocRef> Box<T, A> {
520
522
/// ```
521
523
/// Manually create a `Box` from scratch by using the global allocator:
522
524
/// ```
523
- /// use std::alloc::{alloc, Layout, AllocRef, AllocInit};
525
+ /// #![feature(allocator_api)]
526
+ ///
527
+ /// use std::alloc::{Layout, AllocRef, AllocInit, System};
524
528
///
525
529
/// unsafe {
526
- /// let ptr = System.alloc(Layout::new::<i32>(), AllocInit::Uninitialized) as *mut i32 ;
530
+ /// let ptr = System.alloc(Layout::new::<i32>(), AllocInit::Uninitialized)?.ptr.as_ptr() ;
527
531
/// *ptr = 5;
528
532
/// let x = Box::from_raw_in(ptr, System);
529
533
/// }
534
+ /// # Ok::<_, std::alloc::AllocErr>(())
530
535
/// ```
531
536
///
532
537
/// [memory layout]: index.html#memory-layout
0 commit comments