]> git.lizzy.rs Git - rust.git/commit - src/tools/rustfmt
Auto merge of #75171 - amosonn:new_zeroed_slice, r=Amanieu
authorbors <bors@rust-lang.org>
Sat, 22 Aug 2020 18:46:42 +0000 (18:46 +0000)
committerbors <bors@rust-lang.org>
Sat, 22 Aug 2020 18:46:42 +0000 (18:46 +0000)
commit663d2f5cd3163f17eddb74ee1e028d542255f21a
tree9fa6ffb91539e291d601c8ce585949a3ef830c0e
parent5528caf91442729b47b8f818be0a0ddfd0c17ffb
parent5aba816672d08a076eaa8005a109968af8ce1083
Auto merge of #75171 - amosonn:new_zeroed_slice, r=Amanieu

New zeroed slice

Add to #63291 the methods

```rust
impl<T> Box<[T]> { pub fn new_zeroed_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_zeroed_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_zeroed_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }
```

as suggested in https://github.com/rust-lang/rust/issues/63291#issuecomment-605511675 .

Also optimize `{Rc, Arc}::new_zeroed` to use `alloc_zeroed`, otherwise they are no more efficient than using `new_uninit` and zeroing the memory manually (which was the original implementation).
library/alloc/src/boxed.rs
library/alloc/src/rc.rs
library/alloc/src/sync.rs