@@ -10,24 +10,25 @@ impl Extend<char> for String {
10
10
stream : S ,
11
11
) -> Pin < Box < dyn Future < Output = ( ) > + ' a > > {
12
12
let stream = stream. into_stream ( ) ;
13
- //TODO: Add this back in when size_hint is added to stream
13
+ //TODO: Add this back in when size_hint is added to Stream/StreamExt
14
14
// let (lower_bound, _) = stream.size_hint();
15
15
// self.reserve(lower_bound);
16
16
17
- //TODO: This can just be: stream.for_each(move |c| self.push(c))
18
- Box :: pin ( stream. fold ( ( ) , move |( ) , c| self . push ( c) ) )
17
+ Box :: pin ( stream. for_each ( move |c| self . push ( c) ) )
19
18
}
20
19
}
21
20
22
21
impl < ' b > Extend < & ' b char > for String {
23
22
fn stream_extend < ' a , S : IntoStream < Item = & ' b char > + ' a > (
24
23
& ' a mut self ,
25
- stream : S ,
24
+ //TODO: Remove the underscore when uncommenting the body of this impl
25
+ _stream : S ,
26
26
) -> Pin < Box < dyn Future < Output = ( ) > + ' a > >
27
27
where
28
28
' b : ' a ,
29
29
{
30
- //TODO: Box::pin(stream.into_stream().copied())
30
+ //TODO: This can be uncommented when `copied` is added to Stream/StreamExt
31
+ //Box::pin(stream.into_stream().copied())
31
32
unimplemented ! ( )
32
33
}
33
34
}
@@ -40,8 +41,7 @@ impl<'b> Extend<&'b str> for String {
40
41
where
41
42
' b : ' a ,
42
43
{
43
- //TODO: This can just be: stream.into_stream().for_each(move |s| self.push_str(s))
44
- Box :: pin ( stream. into_stream ( ) . fold ( ( ) , move |( ) , s| self . push_str ( s) ) )
44
+ Box :: pin ( stream. into_stream ( ) . for_each ( move |s| self . push_str ( s) ) )
45
45
}
46
46
}
47
47
@@ -50,12 +50,7 @@ impl Extend<String> for String {
50
50
& ' a mut self ,
51
51
stream : S ,
52
52
) -> Pin < Box < dyn Future < Output = ( ) > + ' a > > {
53
- //TODO: This can just be: stream.into_stream().for_each(move |s| self.push_str(&s))
54
- Box :: pin (
55
- stream
56
- . into_stream ( )
57
- . fold ( ( ) , move |( ) , s| self . push_str ( & s) ) ,
58
- )
53
+ Box :: pin ( stream. into_stream ( ) . for_each ( move |s| self . push_str ( & s) ) )
59
54
}
60
55
}
61
56
@@ -67,11 +62,6 @@ impl<'b> Extend<Cow<'b, str>> for String {
67
62
where
68
63
' b : ' a ,
69
64
{
70
- //TODO: This can just be: stream.into_stream().for_each(move |s| self.push_str(&s))
71
- Box :: pin (
72
- stream
73
- . into_stream ( )
74
- . fold ( ( ) , move |( ) , s| self . push_str ( & s) ) ,
75
- )
65
+ Box :: pin ( stream. into_stream ( ) . for_each ( move |s| self . push_str ( & s) ) )
76
66
}
77
67
}
0 commit comments