File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -729,6 +729,15 @@ impl FromIterator<char> for String {
729
729
}
730
730
}
731
731
732
+ #[ experimental = "waiting on FromIterator stabilization" ]
733
+ impl < ' a > FromIterator < & ' a str > for String {
734
+ fn from_iter < I : Iterator < & ' a str > > ( iterator : I ) -> String {
735
+ let mut buf = String :: new ( ) ;
736
+ buf. extend ( iterator) ;
737
+ buf
738
+ }
739
+ }
740
+
732
741
#[ experimental = "waiting on Extend stabilization" ]
733
742
impl Extend < char > for String {
734
743
fn extend < I : Iterator < char > > ( & mut self , mut iterator : I ) {
@@ -740,6 +749,18 @@ impl Extend<char> for String {
740
749
}
741
750
}
742
751
752
+ #[ experimental = "waiting on Extend stabilization" ]
753
+ impl < ' a > Extend < & ' a str > for String {
754
+ fn extend < I : Iterator < & ' a str > > ( & mut self , mut iterator : I ) {
755
+ // A guess that at least one byte per iterator element will be needed.
756
+ let ( lower_bound, _) = iterator. size_hint ( ) ;
757
+ self . reserve ( lower_bound) ;
758
+ for s in iterator {
759
+ self . push_str ( s)
760
+ }
761
+ }
762
+ }
763
+
743
764
impl PartialEq for String {
744
765
#[ inline]
745
766
fn eq ( & self , other : & String ) -> bool { PartialEq :: eq ( & * * self , & * * other) }
You can’t perform that action at this time.
0 commit comments