Skip to content

Rename stream_extend to extend #464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
3 commits merged into from Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/collections/binary_heap/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::collections::BinaryHeap;
use std::pin::Pin;

use crate::prelude::*;
use crate::stream::{Extend, IntoStream};
use crate::stream::{self, IntoStream};

impl<T: Ord> Extend<T> for BinaryHeap<T> {
fn stream_extend<'a, S: IntoStream<Item = T> + 'a>(
impl<T: Ord> stream::Extend<T> for BinaryHeap<T> {
fn extend<'a, S: IntoStream<Item = T> + 'a>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
Expand Down
4 changes: 2 additions & 2 deletions src/collections/binary_heap/from_stream.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BinaryHeap;
use std::pin::Pin;

use crate::stream::{Extend, FromStream, IntoStream};
use crate::stream::{self, FromStream, IntoStream};

impl<T: Ord> FromStream<T> for BinaryHeap<T> {
#[inline]
Expand All @@ -17,7 +17,7 @@ impl<T: Ord> FromStream<T> for BinaryHeap<T> {
pin_utils::pin_mut!(stream);

let mut out = BinaryHeap::new();
out.stream_extend(stream).await;
stream::Extend::extend(&mut out, stream).await;
out
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/collections/btree_map/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::collections::BTreeMap;
use std::pin::Pin;

use crate::prelude::*;
use crate::stream::{Extend, IntoStream};
use crate::stream::{self, IntoStream};

impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V> {
fn stream_extend<'a, S: IntoStream<Item = (K, V)> + 'a>(
impl<K: Ord, V> stream::Extend<(K, V)> for BTreeMap<K, V> {
fn extend<'a, S: IntoStream<Item = (K, V)> + 'a>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
Expand Down
4 changes: 2 additions & 2 deletions src/collections/btree_map/from_stream.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;
use std::pin::Pin;

use crate::stream::{Extend, FromStream, IntoStream};
use crate::stream::{self, FromStream, IntoStream};

impl<K: Ord, V> FromStream<(K, V)> for BTreeMap<K, V> {
#[inline]
Expand All @@ -17,7 +17,7 @@ impl<K: Ord, V> FromStream<(K, V)> for BTreeMap<K, V> {
pin_utils::pin_mut!(stream);

let mut out = BTreeMap::new();
out.stream_extend(stream).await;
stream::Extend::extend(&mut out, stream).await;
out
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/collections/btree_set/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::collections::BTreeSet;
use std::pin::Pin;

use crate::prelude::*;
use crate::stream::{Extend, IntoStream};
use crate::stream::{self, IntoStream};

impl<T: Ord> Extend<T> for BTreeSet<T> {
fn stream_extend<'a, S: IntoStream<Item = T> + 'a>(
impl<T: Ord> stream::Extend<T> for BTreeSet<T> {
fn extend<'a, S: IntoStream<Item = T> + 'a>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
Expand Down
4 changes: 2 additions & 2 deletions src/collections/btree_set/from_stream.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeSet;
use std::pin::Pin;

use crate::stream::{Extend, FromStream, IntoStream};
use crate::stream::{self, FromStream, IntoStream};

impl<T: Ord> FromStream<T> for BTreeSet<T> {
#[inline]
Expand All @@ -17,7 +17,7 @@ impl<T: Ord> FromStream<T> for BTreeSet<T> {
pin_utils::pin_mut!(stream);

let mut out = BTreeSet::new();
out.stream_extend(stream).await;
stream::Extend::extend(&mut out, stream).await;
out
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/collections/hash_map/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use std::hash::{BuildHasher, Hash};
use std::pin::Pin;

use crate::prelude::*;
use crate::stream::{Extend, IntoStream};
use crate::stream::{self, IntoStream};

impl<K, V, H> Extend<(K, V)> for HashMap<K, V, H>
impl<K, V, H> stream::Extend<(K, V)> for HashMap<K, V, H>
where
K: Eq + Hash,
H: BuildHasher + Default,
{
fn stream_extend<'a, S: IntoStream<Item = (K, V)> + 'a>(
fn extend<'a, S: IntoStream<Item = (K, V)> + 'a>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
Expand Down
4 changes: 2 additions & 2 deletions src/collections/hash_map/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::hash::{BuildHasher, Hash};
use std::pin::Pin;

use crate::stream::{Extend, FromStream, IntoStream};
use crate::stream::{self, FromStream, IntoStream};

impl<K, V, H> FromStream<(K, V)> for HashMap<K, V, H>
where
Expand All @@ -22,7 +22,7 @@ where
pin_utils::pin_mut!(stream);

let mut out = HashMap::with_hasher(Default::default());
out.stream_extend(stream).await;
stream::Extend::extend(&mut out, stream).await;
out
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/collections/hash_set/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use std::hash::{BuildHasher, Hash};
use std::pin::Pin;

use crate::prelude::*;
use crate::stream::{Extend, IntoStream};
use crate::stream::{self, IntoStream};

impl<T, H> Extend<T> for HashSet<T, H>
impl<T, H> stream::Extend<T> for HashSet<T, H>
where
T: Eq + Hash,
H: BuildHasher + Default,
{
fn stream_extend<'a, S: IntoStream<Item = T> + 'a>(
fn extend<'a, S: IntoStream<Item = T> + 'a>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
Expand Down
4 changes: 2 additions & 2 deletions src/collections/hash_set/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashSet;
use std::hash::{BuildHasher, Hash};
use std::pin::Pin;

use crate::stream::{Extend, FromStream, IntoStream};
use crate::stream::{self, FromStream, IntoStream};

impl<T, H> FromStream<T> for HashSet<T, H>
where
Expand All @@ -22,7 +22,7 @@ where
pin_utils::pin_mut!(stream);

let mut out = HashSet::with_hasher(Default::default());
out.stream_extend(stream).await;
stream::Extend::extend(&mut out, stream).await;
out
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/collections/linked_list/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::collections::LinkedList;
use std::pin::Pin;

use crate::prelude::*;
use crate::stream::{Extend, IntoStream};
use crate::stream::{self, IntoStream};

impl<T> Extend<T> for LinkedList<T> {
fn stream_extend<'a, S: IntoStream<Item = T> + 'a>(
impl<T> stream::Extend<T> for LinkedList<T> {
fn extend<'a, S: IntoStream<Item = T> + 'a>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
Expand Down
4 changes: 2 additions & 2 deletions src/collections/linked_list/from_stream.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::LinkedList;
use std::pin::Pin;

use crate::stream::{Extend, FromStream, IntoStream};
use crate::stream::{self, FromStream, IntoStream};

impl<T> FromStream<T> for LinkedList<T> {
#[inline]
Expand All @@ -17,7 +17,7 @@ impl<T> FromStream<T> for LinkedList<T> {
pin_utils::pin_mut!(stream);

let mut out = LinkedList::new();
out.stream_extend(stream).await;
stream::Extend::extend(&mut out, stream).await;
out
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/collections/vec_deque/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::collections::VecDeque;
use std::pin::Pin;

use crate::prelude::*;
use crate::stream::{Extend, IntoStream};
use crate::stream::{self, IntoStream};

impl<T> Extend<T> for VecDeque<T> {
fn stream_extend<'a, S: IntoStream<Item = T> + 'a>(
impl<T> stream::Extend<T> for VecDeque<T> {
fn extend<'a, S: IntoStream<Item = T> + 'a>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
Expand Down
4 changes: 2 additions & 2 deletions src/collections/vec_deque/from_stream.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::VecDeque;
use std::pin::Pin;

use crate::stream::{Extend, FromStream, IntoStream};
use crate::stream::{self, FromStream, IntoStream};

impl<T> FromStream<T> for VecDeque<T> {
#[inline]
Expand All @@ -17,7 +17,7 @@ impl<T> FromStream<T> for VecDeque<T> {
pin_utils::pin_mut!(stream);

let mut out = VecDeque::new();
out.stream_extend(stream).await;
stream::Extend::extend(&mut out, stream).await;
out
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/path/pathbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::path::Path;
#[cfg(feature = "unstable")]
use crate::prelude::*;
#[cfg(feature = "unstable")]
use crate::stream::{Extend, FromStream, IntoStream};
use crate::stream::{self, FromStream, IntoStream};

/// This struct is an async version of [`std::path::PathBuf`].
///
Expand Down Expand Up @@ -241,8 +241,8 @@ impl AsRef<std::path::Path> for PathBuf {
}

#[cfg(feature = "unstable")]
impl<P: AsRef<Path>> Extend<P> for PathBuf {
fn stream_extend<'a, S: IntoStream<Item = P>>(
impl<P: AsRef<Path>> stream::Extend<P> for PathBuf {
fn extend<'a, S: IntoStream<Item = P>>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>>
Expand Down Expand Up @@ -275,7 +275,7 @@ impl<'b, P: AsRef<Path> + 'b> FromStream<P> for PathBuf {
pin_utils::pin_mut!(stream);

let mut out = Self::new();
out.stream_extend(stream).await;
stream::Extend::extend(&mut out, stream).await;
out
})
}
Expand Down
2 changes: 2 additions & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ cfg_unstable! {
pub use crate::stream::DoubleEndedStream;
#[doc(no_inline)]
pub use crate::stream::ExactSizeStream;
#[doc(no_inline)]
pub use crate::stream::Extend;
}
8 changes: 4 additions & 4 deletions src/stream/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ use crate::stream::IntoStream;
/// # async_std::task::block_on(async {
/// #
/// use async_std::prelude::*;
/// use async_std::stream::{self, Extend};
/// use async_std::stream;
///
/// let mut v: Vec<usize> = vec![1, 2];
/// let s = stream::repeat(3usize).take(3);
/// v.stream_extend(s).await;
/// stream::Extend::extend(&mut v, s).await;
///
/// assert_eq!(v, vec![1, 2, 3, 3, 3]);
/// #
Expand All @@ -31,7 +31,7 @@ use crate::stream::IntoStream;
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub trait Extend<A> {
/// Extends a collection with the contents of a stream.
fn stream_extend<'a, T: IntoStream<Item = A> + 'a>(
fn extend<'a, T: IntoStream<Item = A> + 'a>(
&'a mut self,
stream: T,
) -> Pin<Box<dyn Future<Output = ()> + 'a>>
Expand All @@ -40,7 +40,7 @@ pub trait Extend<A> {
}

impl Extend<()> for () {
fn stream_extend<'a, T: IntoStream<Item = ()> + 'a>(
fn extend<'a, T: IntoStream<Item = ()> + 'a>(
&'a mut self,
stream: T,
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
Expand Down
5 changes: 2 additions & 3 deletions src/stream/from_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ use std::pin::Pin;
///
/// ```
/// use async_std::prelude::*;
/// use async_std::stream::{Extend, FromStream, IntoStream};
/// use async_std::stream;
/// use async_std::stream::{self, FromStream, IntoStream};
/// use std::pin::Pin;
///
/// // A sample collection, that's just a wrapper over Vec<T>
Expand Down Expand Up @@ -77,7 +76,7 @@ use std::pin::Pin;
/// let mut c = MyCollection::new();
///
/// let mut v = vec![];
/// v.stream_extend(stream).await;
/// stream::Extend::extend(&mut v, stream).await;
///
/// for i in v {
/// c.add(i);
Expand Down
22 changes: 11 additions & 11 deletions src/string/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::borrow::Cow;
use std::pin::Pin;

use crate::prelude::*;
use crate::stream::{Extend, IntoStream};
use crate::stream::{self, IntoStream};

impl Extend<char> for String {
fn stream_extend<'a, S: IntoStream<Item = char> + 'a>(
impl stream::Extend<char> for String {
fn extend<'a, S: IntoStream<Item = char> + 'a>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
Expand All @@ -17,8 +17,8 @@ impl Extend<char> for String {
}
}

impl<'b> Extend<&'b char> for String {
fn stream_extend<'a, S: IntoStream<Item = &'b char> + 'a>(
impl<'b> stream::Extend<&'b char> for String {
fn extend<'a, S: IntoStream<Item = &'b char> + 'a>(
&'a mut self,
//TODO: Remove the underscore when uncommenting the body of this impl
_stream: S,
Expand All @@ -32,8 +32,8 @@ impl<'b> Extend<&'b char> for String {
}
}

impl<'b> Extend<&'b str> for String {
fn stream_extend<'a, S: IntoStream<Item = &'b str> + 'a>(
impl<'b> stream::Extend<&'b str> for String {
fn extend<'a, S: IntoStream<Item = &'b str> + 'a>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>>
Expand All @@ -44,17 +44,17 @@ impl<'b> Extend<&'b str> for String {
}
}

impl Extend<String> for String {
fn stream_extend<'a, S: IntoStream<Item = String> + 'a>(
impl stream::Extend<String> for String {
fn extend<'a, S: IntoStream<Item = String> + 'a>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
Box::pin(stream.into_stream().for_each(move |s| self.push_str(&s)))
}
}

impl<'b> Extend<Cow<'b, str>> for String {
fn stream_extend<'a, S: IntoStream<Item = Cow<'b, str>> + 'a>(
impl<'b> stream::Extend<Cow<'b, str>> for String {
fn extend<'a, S: IntoStream<Item = Cow<'b, str>> + 'a>(
&'a mut self,
stream: S,
) -> Pin<Box<dyn Future<Output = ()> + 'a>>
Expand Down
Loading