|
|
@ -10,24 +10,25 @@ impl Extend<char> for String {
|
|
|
|
stream: S,
|
|
|
|
stream: S,
|
|
|
|
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
|
|
|
|
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
|
|
|
|
let stream = stream.into_stream();
|
|
|
|
let stream = stream.into_stream();
|
|
|
|
//TODO: Add this back in when size_hint is added to stream
|
|
|
|
//TODO: Add this back in when size_hint is added to Stream/StreamExt
|
|
|
|
// let (lower_bound, _) = stream.size_hint();
|
|
|
|
// let (lower_bound, _) = stream.size_hint();
|
|
|
|
// self.reserve(lower_bound);
|
|
|
|
// self.reserve(lower_bound);
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: This can just be: stream.for_each(move |c| self.push(c))
|
|
|
|
Box::pin(stream.for_each(move |c| self.push(c)))
|
|
|
|
Box::pin(stream.fold((), move |(), c| self.push(c)))
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl<'b> Extend<&'b char> for String {
|
|
|
|
impl<'b> Extend<&'b char> for String {
|
|
|
|
fn stream_extend<'a, S: IntoStream<Item = &'b char> + 'a>(
|
|
|
|
fn stream_extend<'a, S: IntoStream<Item = &'b char> + 'a>(
|
|
|
|
&'a mut self,
|
|
|
|
&'a mut self,
|
|
|
|
stream: S,
|
|
|
|
//TODO: Remove the underscore when uncommenting the body of this impl
|
|
|
|
|
|
|
|
_stream: S,
|
|
|
|
) -> Pin<Box<dyn Future<Output = ()> + 'a>>
|
|
|
|
) -> Pin<Box<dyn Future<Output = ()> + 'a>>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
'b: 'a,
|
|
|
|
'b: 'a,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//TODO: Box::pin(stream.into_stream().copied())
|
|
|
|
//TODO: This can be uncommented when `copied` is added to Stream/StreamExt
|
|
|
|
|
|
|
|
//Box::pin(stream.into_stream().copied())
|
|
|
|
unimplemented!()
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -40,8 +41,7 @@ impl<'b> Extend<&'b str> for String {
|
|
|
|
where
|
|
|
|
where
|
|
|
|
'b: 'a,
|
|
|
|
'b: 'a,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//TODO: This can just be: stream.into_stream().for_each(move |s| self.push_str(s))
|
|
|
|
Box::pin(stream.into_stream().for_each(move |s| self.push_str(s)))
|
|
|
|
Box::pin(stream.into_stream().fold((), move |(), s| self.push_str(s)))
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -50,12 +50,7 @@ impl Extend<String> for String {
|
|
|
|
&'a mut self,
|
|
|
|
&'a mut self,
|
|
|
|
stream: S,
|
|
|
|
stream: S,
|
|
|
|
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
|
|
|
|
) -> Pin<Box<dyn Future<Output = ()> + 'a>> {
|
|
|
|
//TODO: This can just be: stream.into_stream().for_each(move |s| self.push_str(&s))
|
|
|
|
Box::pin(stream.into_stream().for_each(move |s| self.push_str(&s)))
|
|
|
|
Box::pin(
|
|
|
|
|
|
|
|
stream
|
|
|
|
|
|
|
|
.into_stream()
|
|
|
|
|
|
|
|
.fold((), move |(), s| self.push_str(&s)),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -67,11 +62,6 @@ impl<'b> Extend<Cow<'b, str>> for String {
|
|
|
|
where
|
|
|
|
where
|
|
|
|
'b: 'a,
|
|
|
|
'b: 'a,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//TODO: This can just be: stream.into_stream().for_each(move |s| self.push_str(&s))
|
|
|
|
Box::pin(stream.into_stream().for_each(move |s| self.push_str(&s)))
|
|
|
|
Box::pin(
|
|
|
|
|
|
|
|
stream
|
|
|
|
|
|
|
|
.into_stream()
|
|
|
|
|
|
|
|
.fold((), move |(), s| self.push_str(&s)),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|