@@ -147,8 +147,10 @@ use core::slice;
147
147
use core:: task:: { Context , Poll } ;
148
148
149
149
use crate :: alloc:: { self , AllocRef , Global } ;
150
+ use crate :: borrow:: Cow ;
150
151
use crate :: raw_vec:: RawVec ;
151
152
use crate :: str:: from_boxed_utf8_unchecked;
153
+ use crate :: string:: String ;
152
154
use crate :: vec:: Vec ;
153
155
154
156
/// A pointer type for heap allocation.
@@ -1045,6 +1047,41 @@ impl<A> FromIterator<A> for Box<[A]> {
1045
1047
}
1046
1048
}
1047
1049
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
+
1048
1085
#[ stable( feature = "box_slice_clone" , since = "1.3.0" ) ]
1049
1086
impl < T : Clone > Clone for Box < [ T ] > {
1050
1087
fn clone ( & self ) -> Self {
0 commit comments