mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Add basic 'shared_from_iter' impls.
This commit is contained in:
parent
3c805ce183
commit
689c64c469
@ -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
|
/// `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`
|
/// managed value. The value is accessed by calling [`upgrade`] on the `Weak`
|
||||||
/// pointer, which returns an [`Option`]`<`[`Rc`]`<T>>`.
|
/// pointer, which returns an [`Option`]`<`[`Rc`]`<T>>`.
|
||||||
|
@ -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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::boxed::Box;
|
use std::boxed::Box;
|
||||||
|
Loading…
Reference in New Issue
Block a user