Lines Matching defs:new
16 //! let boxed: Box<u8> = Box::new(val);
22 //! let boxed: Box<u8> = Box::new(5);
35 //! let list: List<i32> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil))));
71 //! not valid. The recommended way to build a Box to a ZST if `Box::new` cannot
105 //! Box::new(Foo)
212 /// let five = Box::new(5);
219 pub fn new(x: T) -> Self {
221 Box::new(x)
224 /// Constructs a new box with uninitialized contents.
250 /// Constructs a new `Box` with uninitialized contents, with the memory
276 /// Constructs a new `Pin<Box<T>>`. If `T` does not implement [`Unpin`], then
280 /// does the same as <code>[Box::into_pin]\([Box::new]\(x))</code>. Consider using
282 /// construct a (pinned) `Box` in a different way than with [`Box::new`].
288 Box::new(x).into()
310 /// Constructs a new box with uninitialized contents on the heap,
337 /// Constructs a new `Box` with uninitialized contents, with the memory
421 /// Constructs a new box with uninitialized contents in the provided allocator.
449 let layout = Layout::new::<mem::MaybeUninit<T>>();
458 /// Constructs a new box with uninitialized contents in the provided allocator,
489 let layout = Layout::new::<mem::MaybeUninit<T>>();
495 /// Constructs a new `Box` with uninitialized contents, with the memory
523 let layout = Layout::new::<mem::MaybeUninit<T>>();
532 /// Constructs a new `Box` with uninitialized contents, with the memory
563 let layout = Layout::new::<mem::MaybeUninit<T>>();
569 /// Constructs a new `Pin<Box<T, A>>`. If `T` does not implement [`Unpin`], then
603 /// let c = Box::new(5);
615 /// Constructs a new boxed slice with uninitialized contents.
642 /// Constructs a new boxed slice with uninitialized contents, with the memory
667 /// Constructs a new boxed slice with uninitialized contents. Returns an error if
702 /// Constructs a new boxed slice with uninitialized contents, with the memory
738 /// Constructs a new boxed slice with uninitialized contents in the provided allocator.
768 /// Constructs a new boxed slice with uninitialized contents in the provided allocator,
931 /// let x = Box::new(5);
940 /// let ptr = alloc(Layout::new::<i32>()) as *mut i32;
995 /// let ptr = System.allocate(Layout::new::<i32>())?.as_mut_ptr() as *mut i32;
1034 /// let x = Box::new(String::from("Hello"));
1044 /// let x = Box::new(String::from("Hello"));
1048 /// dealloc(p as *mut u8, Layout::new::<String>());
1100 /// alloc.deallocate(non_null.cast(), Layout::new::<String>());
1162 /// let x = Box::new(41);
1182 unsafe { &mut *mem::ManuallyDrop::new(b).0.as_ptr() }
1192 /// Constructing and pinning a `Box` with <code>Box::into_pin([Box::new]\(x))</code>
1195 /// constructing a (pinned) `Box` in a different way than with [`Box::new`].
1208 /// Pin::new(Foo)
1212 /// let foo = Box::new(());
1251 Box::new(T::default())
1282 /// Returns a new box with a `clone()` of this box's contents.
1287 /// let x = Box::new(5);
1306 /// Copies `source`'s contents into `self` without creating a new allocation.
1311 /// let x = Box::new(5);
1312 /// let mut y = Box::new(10);
1454 /// let boxed = Box::new(5);
1459 Box::new(t)
1475 /// Constructing and pinning a `Box` with <code><Pin<Box\<T>>>::from([Box::new]\(x))</code>
1478 /// constructing a (pinned) `Box` in a different way than with [`Box::new`].
1645 Box::new(array)
1672 /// new memory allocation.
1735 /// print_if_string(Box::new(my_string));
1736 /// print_if_string(Box::new(0i8));
1755 /// let x: Box<dyn Any> = Box::new(1_usize);
1794 /// print_if_string(Box::new(my_string));
1795 /// print_if_string(Box::new(0i8));
1814 /// let x: Box<dyn Any + Send> = Box::new(1_usize);
1853 /// print_if_string(Box::new(my_string));
1854 /// print_if_string(Box::new(0i8));
1873 /// let x: Box<dyn Any + Send + Sync> = Box::new(1_usize);
2122 G::resume(Pin::new(&mut *self), arg)
2147 F::poll(Pin::new(&mut *self), cx)
2156 Pin::new(&mut **self).poll_next(cx)
2238 Box::new(err)
2277 Box::new(err)
2321 Box::new(StringError(err))