Skip to content

Commit 689c64c

Browse files
committed
Add basic 'shared_from_iter' impls.
1 parent 3c805ce commit 689c64c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/liballoc/rc.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,13 @@ impl<T> From<Vec<T>> for Rc<[T]> {
12131213
}
12141214
}
12151215

1216+
#[stable(feature = "shared_from_iter", since = "1.37.0")]
1217+
impl<T> core::iter::FromIterator<T> for Rc<[T]> {
1218+
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
1219+
iter.into_iter().collect::<Vec<T>>().into()
1220+
}
1221+
}
1222+
12161223
/// `Weak` is a version of [`Rc`] that holds a non-owning reference to the
12171224
/// managed value. The value is accessed by calling [`upgrade`] on the `Weak`
12181225
/// pointer, which returns an [`Option`]`<`[`Rc`]`<T>>`.

src/liballoc/sync.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,13 @@ impl<T> From<Vec<T>> for Arc<[T]> {
17851785
}
17861786
}
17871787

1788+
#[stable(feature = "shared_from_iter", since = "1.37.0")]
1789+
impl<T> core::iter::FromIterator<T> for Arc<[T]> {
1790+
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
1791+
iter.into_iter().collect::<Vec<T>>().into()
1792+
}
1793+
}
1794+
17881795
#[cfg(test)]
17891796
mod tests {
17901797
use std::boxed::Box;

0 commit comments

Comments
 (0)