File tree 3 files changed +15
-5
lines changed
3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -729,10 +729,20 @@ impl String {
729
729
/// Note that this will drop any excess capacity.
730
730
#[ unstable( feature = "box_str" ,
731
731
reason = "recently added, matches RFC" ) ]
732
- pub fn into_boxed_slice ( self ) -> Box < str > {
732
+ pub fn into_boxed_str ( self ) -> Box < str > {
733
733
let slice = self . vec . into_boxed_slice ( ) ;
734
734
unsafe { mem:: transmute :: < Box < [ u8 ] > , Box < str > > ( slice) }
735
735
}
736
+
737
+ /// Converts the string into `Box<str>`.
738
+ ///
739
+ /// Note that this will drop any excess capacity.
740
+ #[ unstable( feature = "box_str" ,
741
+ reason = "recently added, matches RFC" ) ]
742
+ #[ deprecated( since = "1.4.0" , reason = "renamed to `into_boxed_str`" ) ]
743
+ pub fn into_boxed_slice ( self ) -> Box < str > {
744
+ self . into_boxed_str ( )
745
+ }
736
746
}
737
747
738
748
impl FromUtf8Error {
Original file line number Diff line number Diff line change @@ -1204,13 +1204,13 @@ fn test_into_string() {
1204
1204
// The only way to acquire a Box<str> in the first place is through a String, so just
1205
1205
// test that we can round-trip between Box<str> and String.
1206
1206
let string = String :: from ( "Some text goes here" ) ;
1207
- assert_eq ! ( string. clone( ) . into_boxed_slice ( ) . into_string( ) , string) ;
1207
+ assert_eq ! ( string. clone( ) . into_boxed_str ( ) . into_string( ) , string) ;
1208
1208
}
1209
1209
1210
1210
#[ test]
1211
1211
fn test_box_slice_clone ( ) {
1212
1212
let data = String :: from ( "hello HELLO hello HELLO yes YES 5 中ä华!!!" ) ;
1213
- let data2 = data. clone ( ) . into_boxed_slice ( ) . clone ( ) . into_string ( ) ;
1213
+ let data2 = data. clone ( ) . into_boxed_str ( ) . clone ( ) . into_string ( ) ;
1214
1214
1215
1215
assert_eq ! ( data, data2) ;
1216
1216
}
Original file line number Diff line number Diff line change @@ -366,9 +366,9 @@ fn test_extend_ref() {
366
366
}
367
367
368
368
#[ test]
369
- fn test_into_boxed_slice ( ) {
369
+ fn test_into_boxed_str ( ) {
370
370
let xs = String :: from ( "hello my name is bob" ) ;
371
- let ys = xs. into_boxed_slice ( ) ;
371
+ let ys = xs. into_boxed_str ( ) ;
372
372
assert_eq ! ( & * ys, "hello my name is bob" ) ;
373
373
}
374
374
You can’t perform that action at this time.
0 commit comments