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 @@ -747,10 +747,20 @@ impl String {
747
747
/// Note that this will drop any excess capacity.
748
748
#[ unstable( feature = "box_str" ,
749
749
reason = "recently added, matches RFC" ) ]
750
- pub fn into_boxed_slice ( self ) -> Box < str > {
750
+ pub fn into_boxed_str ( self ) -> Box < str > {
751
751
let slice = self . vec . into_boxed_slice ( ) ;
752
752
unsafe { mem:: transmute :: < Box < [ u8 ] > , Box < str > > ( slice) }
753
753
}
754
+
755
+ /// Converts the string into `Box<str>`.
756
+ ///
757
+ /// Note that this will drop any excess capacity.
758
+ #[ unstable( feature = "box_str" ,
759
+ reason = "recently added, matches RFC" ) ]
760
+ #[ deprecated( since = "1.4.0" , reason = "renamed to `into_boxed_str`" ) ]
761
+ pub fn into_boxed_slice ( self ) -> Box < str > {
762
+ self . into_boxed_str ( )
763
+ }
754
764
}
755
765
756
766
impl FromUtf8Error {
Original file line number Diff line number Diff line change @@ -1763,13 +1763,13 @@ fn test_into_string() {
1763
1763
// The only way to acquire a Box<str> in the first place is through a String, so just
1764
1764
// test that we can round-trip between Box<str> and String.
1765
1765
let string = String :: from ( "Some text goes here" ) ;
1766
- assert_eq ! ( string. clone( ) . into_boxed_slice ( ) . into_string( ) , string) ;
1766
+ assert_eq ! ( string. clone( ) . into_boxed_str ( ) . into_string( ) , string) ;
1767
1767
}
1768
1768
1769
1769
#[ test]
1770
1770
fn test_box_slice_clone ( ) {
1771
1771
let data = String :: from ( "hello HELLO hello HELLO yes YES 5 中ä华!!!" ) ;
1772
- let data2 = data. clone ( ) . into_boxed_slice ( ) . clone ( ) . into_string ( ) ;
1772
+ let data2 = data. clone ( ) . into_boxed_str ( ) . clone ( ) . into_string ( ) ;
1773
1773
1774
1774
assert_eq ! ( data, data2) ;
1775
1775
}
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