File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed
Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -747,10 +747,20 @@ impl String {
747747 /// Note that this will drop any excess capacity.
748748 #[ unstable( feature = "box_str" ,
749749 reason = "recently added, matches RFC" ) ]
750- pub fn into_boxed_slice ( self ) -> Box < str > {
750+ pub fn into_boxed_str ( self ) -> Box < str > {
751751 let slice = self . vec . into_boxed_slice ( ) ;
752752 unsafe { mem:: transmute :: < Box < [ u8 ] > , Box < str > > ( slice) }
753753 }
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+ }
754764}
755765
756766impl FromUtf8Error {
Original file line number Diff line number Diff line change @@ -1763,13 +1763,13 @@ fn test_into_string() {
17631763 // The only way to acquire a Box<str> in the first place is through a String, so just
17641764 // test that we can round-trip between Box<str> and String.
17651765 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) ;
17671767}
17681768
17691769#[ test]
17701770fn test_box_slice_clone ( ) {
17711771 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 ( ) ;
17731773
17741774 assert_eq ! ( data, data2) ;
17751775}
Original file line number Diff line number Diff line change @@ -366,9 +366,9 @@ fn test_extend_ref() {
366366}
367367
368368#[ test]
369- fn test_into_boxed_slice ( ) {
369+ fn test_into_boxed_str ( ) {
370370 let xs = String :: from ( "hello my name is bob" ) ;
371- let ys = xs. into_boxed_slice ( ) ;
371+ let ys = xs. into_boxed_str ( ) ;
372372 assert_eq ! ( & * ys, "hello my name is bob" ) ;
373373}
374374
You can’t perform that action at this time.
0 commit comments