Lines Matching +full:sometimes +full:- +full:uninitialized
55 //! For non-zero-sized values, a [`Box`] will use the [`Global`] allocator for
65 //! For zero-sized values, the `Box` pointer still has to be [valid] for reads
67 //! non-zero integer literal to a raw pointer produces a valid pointer, but a
73 //! as a single pointer and is also ABI-compatible with C pointers
87 //! /* Takes ownership from the caller; no-op when invoked with null */
102 //! pub extern "C" fn foo_new() -> Box<Foo> {
113 //! non-null pointers. Moreover, the destructor for `Box<T>` will attempt to
123 //! described in [rust-lang/unsafe-code-guidelines#198][ucg#198].
135 //! [rust-lang/unsafe-code-guidelines#326][ucg#326].
138 //! [ucg#198]: https://github.com/rust-lang/unsafe-code-guidelines/issues/198
139 //! [ucg#326]: https://github.com/rust-lang/unsafe-code-guidelines/issues/326
188 /// See the [module-level documentation](../../std/boxed/index.html) for more.
203 /// This doesn't actually allocate if `T` is zero-sized.
215 pub fn new(x: T) -> Self { in new()
220 /// Constructs a new box with uninitialized contents.
242 pub fn new_uninit() -> Box<mem::MaybeUninit<T>> { in new_uninit()
246 /// Constructs a new `Box` with uninitialized contents, with the memory
268 pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> { in new_zeroed()
283 pub fn pin(x: T) -> Pin<Box<T>> { in pin()
290 /// This doesn't actually allocate if `T` is zero-sized.
302 pub fn try_new(x: T) -> Result<Self, AllocError> { in try_new()
306 /// Constructs a new box with uninitialized contents on the heap,
329 pub fn try_new_uninit() -> Result<Box<mem::MaybeUninit<T>>, AllocError> { in try_new_uninit()
333 /// Constructs a new `Box` with uninitialized contents, with the memory
355 pub fn try_new_zeroed() -> Result<Box<mem::MaybeUninit<T>>, AllocError> { in try_new_zeroed()
363 /// This doesn't actually allocate if `T` is zero-sized.
378 pub fn new_in(x: T, alloc: A) -> Self in new_in()
392 /// This doesn't actually allocate if `T` is zero-sized.
406 pub fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError> in try_new_in()
417 /// Constructs a new box with uninitialized contents in the provided allocator.
441 pub fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A> in new_uninit_in()
446 // NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable. in new_uninit_in()
454 /// Constructs a new box with uninitialized contents in the provided allocator,
478 pub fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError> in try_new_uninit_in()
487 /// Constructs a new `Box` with uninitialized contents, with the memory
511 pub fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A> in new_zeroed_in()
516 // NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable. in new_zeroed_in()
524 /// Constructs a new `Box` with uninitialized contents, with the memory
548 pub fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError> in try_new_zeroed_in()
568 pub fn pin_in(x: T, alloc: A) -> Pin<Self> in pin_in()
579 pub fn into_boxed_slice(boxed: Self) -> Box<[T], A> { in into_boxed_slice()
597 pub fn into_inner(boxed: Self) -> T { in into_inner()
603 /// Constructs a new boxed slice with uninitialized contents.
626 pub fn new_uninit_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> { in new_uninit_slice()
630 /// Constructs a new boxed slice with uninitialized contents, with the memory
651 pub fn new_zeroed_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> { in new_zeroed_slice()
655 /// Constructs a new boxed slice with uninitialized contents. Returns an error if
677 pub fn try_new_uninit_slice(len: usize) -> Result<Box<[mem::MaybeUninit<T>]>, AllocError> { in try_new_uninit_slice()
688 /// Constructs a new boxed slice with uninitialized contents, with the memory
709 pub fn try_new_zeroed_slice(len: usize) -> Result<Box<[mem::MaybeUninit<T>]>, AllocError> { in try_new_zeroed_slice()
722 /// Constructs a new boxed slice with uninitialized contents in the provided allocator.
748 pub fn new_uninit_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> { in new_uninit_slice_in()
752 /// Constructs a new boxed slice with uninitialized contents in the provided allocator,
776 pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> { in new_zeroed_slice_in()
812 pub unsafe fn assume_init(self) -> Box<T, A> { in assume_init()
846 pub fn write(mut boxed: Self, value: T) -> Box<T, A> { in write()
887 pub unsafe fn assume_init(self) -> Box<[T], A> { in assume_init()
905 /// memory problems. For example, a double-free may occur if the
926 /// // the (uninitialized) previous contents of `ptr`, though for this
933 /// [memory layout]: self#memory-layout
938 pub unsafe fn from_raw(raw: *mut T) -> Self { in from_raw()
955 /// memory problems. For example, a double-free may occur if the
981 /// // the (uninitialized) previous contents of `ptr`, though for this
989 /// [memory layout]: self#memory-layout
994 pub const unsafe fn from_raw_in(raw: *mut T, alloc: A) -> Self { in from_raw_in()
1000 /// The pointer will be properly aligned and non-null.
1036 /// [memory layout]: self#memory-layout
1039 pub fn into_raw(b: Self) -> *mut T { in into_raw()
1045 /// The pointer will be properly aligned and non-null.
1088 /// [memory layout]: self#memory-layout
1091 pub fn into_raw_with_allocator(b: Self) -> (*mut T, A) { in into_raw_with_allocator()
1103 pub fn into_unique(b: Self) -> (Unique<T>, A) { in into_unique()
1121 pub const fn allocator(b: &Self) -> &A { in allocator()
1162 pub fn leak<'a>(b: Self) -> &'a mut T in leak()
1191 /// fn from(_: Box<()>) -> Pin<Foo> {
1201 pub const fn into_pin(boxed: Self) -> Pin<Self> in into_pin()
1232 fn default() -> Self { in default()
1241 fn default() -> Self { in default()
1251 fn default() -> Self { in default()
1279 fn clone(&self) -> Self { in clone()
1280 // Pre-allocate memory to allow writing the cloned value directly. in clone()
1314 fn clone(&self) -> Self { in clone()
1324 fn eq(&self, other: &Self) -> bool { in eq()
1328 fn ne(&self, other: &Self) -> bool { in ne()
1335 fn partial_cmp(&self, other: &Self) -> Option<Ordering> { in partial_cmp()
1339 fn lt(&self, other: &Self) -> bool { in lt()
1343 fn le(&self, other: &Self) -> bool { in le()
1347 fn ge(&self, other: &Self) -> bool { in ge()
1351 fn gt(&self, other: &Self) -> bool { in gt()
1358 fn cmp(&self, other: &Self) -> Ordering { in cmp()
1374 fn finish(&self) -> u64 { in finish()
1440 fn from(t: T) -> Self { in from()
1461 fn from(boxed: Box<T, A>) -> Self { in from()
1469 fn from_slice(slice: &[T]) -> Self; in from_slice()
1475 default fn from_slice(slice: &[T]) -> Self { in from_slice()
1483 fn from_slice(slice: &[T]) -> Self { in from_slice()
1510 fn from(slice: &[T]) -> Box<[T]> { in from()
1525 fn from(cow: Cow<'_, [T]>) -> Box<[T]> { in from()
1548 fn from(s: &str) -> Box<str> { in from()
1580 fn from(cow: Cow<'_, str>) -> Box<str> { in from()
1607 fn from(s: Box<str, A>) -> Self { in from()
1618 /// This conversion moves the array to newly heap-allocated memory.
1626 fn from(array: [T; N]) -> Box<[T]> { in from()
1638 ) -> Box<[T; N], A> { in boxed_slice_as_array_unchecked()
1653 /// The conversion occurs in-place and does not require a
1660 fn try_from(boxed_slice: Box<[T]>) -> Result<Self, Self::Error> { in try_from()
1676 /// Like [`Vec::into_boxed_slice`], this is in-place if `vec.capacity() == N`,
1692 fn try_from(vec: Vec<T>) -> Result<Self, Self::Error> { in try_from()
1722 pub fn downcast<T: Any>(self) -> Result<Box<T, A>, Self> { in downcast()
1752 pub unsafe fn downcast_unchecked<T: Any>(self) -> Box<T, A> { in downcast_unchecked()
1781 pub fn downcast<T: Any>(self) -> Result<Box<T, A>, Self> { in downcast()
1811 pub unsafe fn downcast_unchecked<T: Any>(self) -> Box<T, A> { in downcast_unchecked()
1840 pub fn downcast<T: Any>(self) -> Result<Box<T, A>, Self> { in downcast()
1870 pub unsafe fn downcast_unchecked<T: Any>(self) -> Box<T, A> { in downcast_unchecked()
1882 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt()
1889 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt()
1896 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt()
1908 fn deref(&self) -> &T { in deref()
1915 fn deref_mut(&mut self) -> &mut T { in deref_mut()
1926 fn next(&mut self) -> Option<I::Item> { in next()
1929 fn size_hint(&self) -> (usize, Option<usize>) { in size_hint()
1932 fn nth(&mut self, n: usize) -> Option<I::Item> { in nth()
1935 fn last(self) -> Option<I::Item> { in last()
1942 fn last(self) -> Option<Self::Item>; in last()
1947 default fn last(self) -> Option<I::Item> { in last()
1949 fn some<T>(_: Option<T>, x: T) -> Option<T> { in last()
1961 fn last(self) -> Option<I::Item> { in last()
1968 fn next_back(&mut self) -> Option<I::Item> { in next_back()
1971 fn nth_back(&mut self, n: usize) -> Option<I::Item> { in nth_back()
1977 fn len(&self) -> usize { in len()
1980 fn is_empty(&self) -> bool { in is_empty()
1992 extern "rust-call" fn call_once(self, args: Args) -> Self::Output { in call_once()
1999 extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output { in call_mut()
2006 extern "rust-call" fn call(&self, args: Args) -> Self::Output { in call()
2020 fn from_iter<T: IntoIterator<Item = I>>(iter: T) -> Self { in from_iter()
2028 fn clone(&self) -> Self { in clone()
2044 fn borrow(&self) -> &T { in borrow()
2051 fn borrow_mut(&mut self) -> &mut T { in borrow_mut()
2058 fn as_ref(&self) -> &T { in as_ref()
2065 fn as_mut(&mut self) -> &mut T { in as_mut()
2078 * - Logically, it is helpful to understand pinning in regard to the
2083 * - It is in practice very useful to have Box<T> be unconditionally
2103 fn resume(mut self: Pin<&mut Self>, arg: R) -> GeneratorState<Self::Yield, Self::Return> { in resume()
2116 fn resume(mut self: Pin<&mut Self>, arg: R) -> GeneratorState<Self::Yield, Self::Return> { in resume()
2128 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { in poll()
2137 fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { in poll_next()
2141 fn size_hint(&self) -> (usize, Option<usize>) { in size_hint()
2151 pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<dyn Error>> { in downcast()
2168 pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<dyn Error + Send>> { in downcast()
2182 pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<Self>> { in downcast()
2207 /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2219 fn from(err: E) -> Box<dyn Error + 'a> { in from()
2241 /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2258 fn from(err: E) -> Box<dyn Error + Send + Sync + 'a> { in from()
2280 fn from(err: String) -> Box<dyn Error + Send + Sync> { in from()
2285 fn description(&self) -> &str { in from()
2291 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in from()
2298 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in from()
2322 fn from(str_err: String) -> Box<dyn Error> { in from()
2348 fn from(err: &str) -> Box<dyn Error + Send + Sync + 'a> { in from()
2370 fn from(err: &str) -> Box<dyn Error> { in from()
2392 fn from(err: Cow<'b, str>) -> Box<dyn Error + Send + Sync + 'a> { in from()
2413 fn from(err: Cow<'a, str>) -> Box<dyn Error> { in from()
2421 fn description(&self) -> &str { in description()
2426 fn cause(&self) -> Option<&dyn core::error::Error> { in cause()
2430 fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { in source()