@@ -147,8 +147,10 @@ use core::slice;
147147use core:: task:: { Context , Poll } ;
148148
149149use crate :: alloc:: { self , AllocRef , Global } ;
150+ use crate :: borrow:: Cow ;
150151use crate :: raw_vec:: RawVec ;
151152use crate :: str:: from_boxed_utf8_unchecked;
153+ use crate :: string:: String ;
152154use crate :: vec:: Vec ;
153155
154156/// A pointer type for heap allocation.
@@ -1045,6 +1047,41 @@ impl<A> FromIterator<A> for Box<[A]> {
10451047 }
10461048}
10471049
1050+ #[ stable( feature = "boxed_str_from_iter" , since = "1.44.0" ) ]
1051+ impl < ' a > FromIterator < & ' a char > for Box < str > {
1052+ fn from_iter < T : IntoIterator < Item = & ' a char > > ( iter : T ) -> Self {
1053+ iter. into_iter ( ) . collect :: < String > ( ) . into_boxed_str ( )
1054+ }
1055+ }
1056+
1057+ #[ stable( feature = "boxed_str_from_iter" , since = "1.44.0" ) ]
1058+ impl < ' a > FromIterator < & ' a str > for Box < str > {
1059+ fn from_iter < T : IntoIterator < Item = & ' a str > > ( iter : T ) -> Self {
1060+ iter. into_iter ( ) . collect :: < String > ( ) . into_boxed_str ( )
1061+ }
1062+ }
1063+
1064+ #[ stable( feature = "boxed_str_from_iter" , since = "1.44.0" ) ]
1065+ impl < ' a > FromIterator < Cow < ' a , str > > for Box < str > {
1066+ fn from_iter < T : IntoIterator < Item = Cow < ' a , str > > > ( iter : T ) -> Self {
1067+ iter. into_iter ( ) . collect :: < String > ( ) . into_boxed_str ( )
1068+ }
1069+ }
1070+
1071+ #[ stable( feature = "boxed_str_from_iter" , since = "1.44.0" ) ]
1072+ impl FromIterator < String > for Box < str > {
1073+ fn from_iter < T : IntoIterator < Item = String > > ( iter : T ) -> Self {
1074+ iter. into_iter ( ) . collect :: < String > ( ) . into_boxed_str ( )
1075+ }
1076+ }
1077+
1078+ #[ stable( feature = "boxed_str_from_iter" , since = "1.44.0" ) ]
1079+ impl FromIterator < char > for Box < str > {
1080+ fn from_iter < T : IntoIterator < Item = char > > ( iter : T ) -> Self {
1081+ iter. into_iter ( ) . collect :: < String > ( ) . into_boxed_str ( )
1082+ }
1083+ }
1084+
10481085#[ stable( feature = "box_slice_clone" , since = "1.3.0" ) ]
10491086impl < T : Clone > Clone for Box < [ T ] > {
10501087 fn clone ( & self ) -> Self {
0 commit comments