rust/library/core/src
Yuki Okushi babfdafb10
Rollup merge of #80600 - CoffeeBlend:maybe_uninit_array_assume_init, r=dtolnay
Add `MaybeUninit` method `array_assume_init`

When initialising an array element-by-element, the conversion to the initialised array is done through `mem::transmute`, which is both ugly and does not work with const generics (see #61956). This PR proposes the associated method `array_assume_init`, matching the style of `slice_assume_init_*`:

```rust
unsafe fn array_assume_init<T, const N: usize>(array: [MaybeUninit<T>; N]) -> [T; N];
```

Example:
```rust
let mut array: [MaybeUninit<i32>; 3] = MaybeUninit::uninit_array();
array[0].write(0);
array[1].write(1);
array[2].write(2);

// SAFETY: Now safe as we initialised all elements
let array: [i32; 3] = unsafe {
     MaybeUninit::array_assume_init(array)
};
```

Things I'm unsure about:
* Should this be a method of array instead?
* Should the function be const?
2021-01-12 16:13:24 +09:00
..
alloc Auto merge of #79827 - tmiasko:size-align, r=kennytm 2021-01-03 03:43:29 +00:00
array Add [T; N]::each_ref and [T; N]::each_mut 2021-01-11 01:09:22 -08:00
char Rollup merge of #79502 - Julian-Wollersberger:from_char_for_u64, r=withoutboats 2021-01-10 16:55:53 +09:00
convert Remove many unnecessary manual link resolves from library 2020-12-31 11:54:32 -08:00
fmt Use more std:: instead of core:: in docs for consistency, add more intra doc links 2020-12-02 00:41:53 +01:00
future Use more std:: instead of core:: in docs for consistency, add more intra doc links 2020-12-02 00:41:53 +01:00
hash fix aliasing issues in SipHasher 2020-10-31 16:26:06 +01:00
iter Fix typo in Step trait 2021-01-07 21:29:17 -05:00
macros Bump bootstrap compiler to 1.50 beta 2020-12-30 09:27:19 -05:00
mem Rollup merge of #80600 - CoffeeBlend:maybe_uninit_array_assume_init, r=dtolnay 2021-01-12 16:13:24 +09:00
num Fix typos. 2020-12-30 23:23:02 +01:00
ops small TypeVisitor refactor 2020-12-07 15:52:59 +01:00
prelude mv std libs to library/ 2020-07-27 19:51:13 -05:00
ptr Auto merge of #79684 - usbalbin:const_copy, r=oli-obk 2020-12-30 12:43:02 +00:00
slice Rollup merge of #80791 - mrcz:master, r=jyn514 2021-01-08 11:11:47 +09:00
str Improve wording of parse doc 2021-01-07 07:47:03 +03:00
sync Remove all doc_comment!{} hacks by using #[doc = expr] where needed. 2020-12-30 22:49:08 +01:00
task Use more std:: instead of core:: in docs for consistency, add more intra doc links 2020-12-02 00:41:53 +01:00
unicode Privatize some of libcore unicode_internals 2020-12-07 16:16:42 +03:00
any.rs Apply suggestions from code review 2020-12-09 23:13:24 +00:00
ascii.rs Fixed some intra-docs links in library/core 2020-09-18 07:49:29 +08:00
bool.rs Stabilise then 2020-11-22 13:45:14 +00:00
borrow.rs Remove many unnecessary manual link resolves from library 2020-12-31 11:54:32 -08:00
cell.rs Auto merge of #79485 - EllenNyan:stabilize_unsafe_cell_get_mut, r=m-ou-se 2020-12-18 11:39:26 +00:00
clone.rs Improve readability 2020-09-01 19:56:32 +02:00
cmp.rs fix broken link in PartialEq doc 2021-01-09 22:40:48 -08:00
default.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
ffi.rs Properly define va_arg and va_list for aarch64-apple-darwin 2020-10-25 21:37:01 -04:00
hint.rs Fixed documentation error 2021-01-03 19:54:54 +02:00
internal_macros.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
intrinsics.rs Auto merge of #80717 - mbartlett21:patch-2, r=dtolnay 2021-01-05 14:15:49 +00:00
lazy.rs Capitalize safety comments 2020-09-08 22:26:44 -04:00
lib.rs remove incomplete features from std 2021-01-01 19:57:10 +01:00
marker.rs Auto merge of #77893 - petertodd:2020-impl-default-for-phantompinned, r=dtolnay 2020-11-23 07:00:30 +00:00
option.rs Remove many unnecessary manual link resolves from library 2020-12-31 11:54:32 -08:00
panic.rs Use more std:: instead of core:: in docs for consistency, add more intra doc links 2020-12-02 00:41:53 +01:00
panicking.rs Bump bootstrap compiler version 2020-11-19 19:23:36 -05:00
pin.rs Remove many unnecessary manual link resolves from library 2020-12-31 11:54:32 -08:00
primitive.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
raw.rs Use intra-doc-links in core::{raw, ffi, pin} 2020-08-22 22:25:27 +02:00
result.rs Remove many unnecessary manual link resolves from library 2020-12-31 11:54:32 -08:00
time.rs Remove Duration::MIN entirely 2020-10-27 15:48:58 -07:00
tuple.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
unit.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00