diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-06-19 01:39:51 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-06-20 09:28:12 +0200 |
| commit | 689c64c469152ab6de15c3950d5fe92ba95257f2 (patch) | |
| tree | 336a2f9c61f25b286c9a531dbcc84e81efaf983b /src/liballoc | |
| parent | 3c805ce183840bd20bd81a54a02b3c8b6dccc9dd (diff) | |
Add basic 'shared_from_iter' impls.
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/rc.rs | 7 | ||||
| -rw-r--r-- | src/liballoc/sync.rs | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index ee78839f7f0..df97b0efc6c 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1213,6 +1213,13 @@ impl<T> From<Vec<T>> for Rc<[T]> { } } +#[stable(feature = "shared_from_iter", since = "1.37.0")] +impl<T> core::iter::FromIterator<T> for Rc<[T]> { + fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self { + iter.into_iter().collect::<Vec<T>>().into() + } +} + /// `Weak` is a version of [`Rc`] that holds a non-owning reference to the /// managed value. The value is accessed by calling [`upgrade`] on the `Weak` /// pointer, which returns an [`Option`]`<`[`Rc`]`<T>>`. diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 6c23b3179ed..a0b06fabe32 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -1785,6 +1785,13 @@ impl<T> From<Vec<T>> for Arc<[T]> { } } +#[stable(feature = "shared_from_iter", since = "1.37.0")] +impl<T> core::iter::FromIterator<T> for Arc<[T]> { + fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self { + iter.into_iter().collect::<Vec<T>>().into() + } +} + #[cfg(test)] mod tests { use std::boxed::Box; |
