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 @@ -749,10 +749,20 @@ impl String {
749749 /// Note that this will drop any excess capacity.
750750 #[ unstable( feature = "box_str" ,
751751 reason = "recently added, matches RFC" ) ]
752- pub fn into_boxed_slice ( self ) -> Box < str > {
752+ pub fn into_boxed_str ( self ) -> Box < str > {
753753 let slice = self . vec . into_boxed_slice ( ) ;
754754 unsafe { mem:: transmute :: < Box < [ u8 ] > , Box < str > > ( slice) }
755755 }
756+
757+ /// Converts the string into `Box<str>`.
758+ ///
759+ /// Note that this will drop any excess capacity.
760+ #[ unstable( feature = "box_str" ,
761+ reason = "recently added, matches RFC" ) ]
762+ #[ deprecated( since = "1.4.0" , reason = "renamed to `into_boxed_str`" ) ]
763+ pub fn into_boxed_slice ( self ) -> Box < str > {
764+ self . into_boxed_str ( )
765+ }
756766}
757767
758768impl 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