refactor: moved Vec impl Cow into cow.rs
This commit is contained in:
parent
6bf9608f9f
commit
2580822b91
2 changed files with 37 additions and 35 deletions
|
@ -89,6 +89,8 @@ pub use self::drain::Drain;
|
|||
|
||||
mod drain;
|
||||
|
||||
mod cow;
|
||||
|
||||
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector'.
|
||||
///
|
||||
/// # Examples
|
||||
|
@ -3013,41 +3015,6 @@ impl<T, A: Allocator, const N: usize> TryFrom<Vec<T, A>> for [T; N] {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Clone-on-write
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[stable(feature = "cow_from_vec", since = "1.8.0")]
|
||||
impl<'a, T: Clone> From<&'a [T]> for Cow<'a, [T]> {
|
||||
fn from(s: &'a [T]) -> Cow<'a, [T]> {
|
||||
Cow::Borrowed(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "cow_from_vec", since = "1.8.0")]
|
||||
impl<'a, T: Clone> From<Vec<T>> for Cow<'a, [T]> {
|
||||
fn from(v: Vec<T>) -> Cow<'a, [T]> {
|
||||
Cow::Owned(v)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "cow_from_vec_ref", since = "1.28.0")]
|
||||
impl<'a, T: Clone> From<&'a Vec<T>> for Cow<'a, [T]> {
|
||||
fn from(v: &'a Vec<T>) -> Cow<'a, [T]> {
|
||||
Cow::Borrowed(v.as_slice())
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, T> FromIterator<T> for Cow<'a, [T]>
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
fn from_iter<I: IntoIterator<Item = T>>(it: I) -> Cow<'a, [T]> {
|
||||
Cow::Owned(FromIterator::from_iter(it))
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Iterators
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue