diff --git a/src/string/extend.rs b/src/string/extend.rs index feac1a4..72260a5 100644 --- a/src/string/extend.rs +++ b/src/string/extend.rs @@ -10,24 +10,25 @@ impl Extend for String { stream: S, ) -> Pin + 'a>> { 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(); // self.reserve(lower_bound); - //TODO: This can just be: stream.for_each(move |c| self.push(c)) - Box::pin(stream.fold((), move |(), c| self.push(c))) + Box::pin(stream.for_each(move |c| self.push(c))) } } impl<'b> Extend<&'b char> for String { fn stream_extend<'a, S: IntoStream + 'a>( &'a mut self, - stream: S, + //TODO: Remove the underscore when uncommenting the body of this impl + _stream: S, ) -> Pin + 'a>> where '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!() } } @@ -40,8 +41,7 @@ impl<'b> Extend<&'b str> for String { where 'b: 'a, { - //TODO: This can just be: stream.into_stream().for_each(move |s| self.push_str(s)) - Box::pin(stream.into_stream().fold((), move |(), s| self.push_str(s))) + Box::pin(stream.into_stream().for_each(move |s| self.push_str(s))) } } @@ -50,12 +50,7 @@ impl Extend for String { &'a mut self, stream: S, ) -> Pin + 'a>> { - //TODO: This can just be: stream.into_stream().for_each(move |s| self.push_str(&s)) - Box::pin( - stream - .into_stream() - .fold((), move |(), s| self.push_str(&s)), - ) + Box::pin(stream.into_stream().for_each(move |s| self.push_str(&s))) } } @@ -67,11 +62,6 @@ impl<'b> Extend> for String { where 'b: 'a, { - //TODO: This can just be: stream.into_stream().for_each(move |s| self.push_str(&s)) - Box::pin( - stream - .into_stream() - .fold((), move |(), s| self.push_str(&s)), - ) + Box::pin(stream.into_stream().for_each(move |s| self.push_str(&s))) } }