Skip to content

Commit

Permalink
Auto merge of #61953 - Centril:shared-from-iter, r=RalfJung
Browse files Browse the repository at this point in the history
Add `impl<T> FromIterator<T> for Arc/Rc<[T]>`

Add implementations of `FromIterator<T> for Arc/Rc<[T]>` with symmetrical logic.

This also takes advantage of specialization in the case of iterators with known length (`TrustedLen`) to elide the final allocation/copying from a `Vec<T>` into `Rc<[T]>` because we can allocate the space for the `Rc<[T]>` directly when the size is known. This is the primary motivation and why this is to be preferred over `iter.collect::<Vec<_>>().into(): Rc<[T]>`.

Moreover, this PR does some refactoring in some places.

r? @RalfJung for the code
cc @alexcrichton from T-libs
  • Loading branch information
bors committed Jul 13, 2019
2 parents a9c7feb + 85def30 commit 4a95e97
Show file tree
Hide file tree
Showing 6 changed files with 652 additions and 140 deletions.
1 change: 1 addition & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
#![feature(ptr_offset_from)]
#![feature(rustc_attrs)]
#![feature(receiver_trait)]
#![feature(slice_from_raw_parts)]
#![feature(specialization)]
#![feature(staged_api)]
#![feature(std_internals)]
Expand Down
Loading

0 comments on commit 4a95e97

Please sign in to comment.