File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 125125#![ feature( inclusive_range_methods) ]
126126#![ cfg_attr( stage0, feature( generic_param_attrs) ) ]
127127#![ feature( rustc_const_unstable) ]
128+ #![ feature( const_vec_new) ]
128129
129130#![ cfg_attr( not( test) , feature( fn_traits, i128 ) ) ]
130131#![ cfg_attr( test, feature( test) ) ]
Original file line number Diff line number Diff line change @@ -380,7 +380,8 @@ impl String {
380380 /// ```
381381 #[ inline]
382382 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
383- pub fn new ( ) -> String {
383+ #[ rustc_const_unstable( feature = "const_string_new" ) ]
384+ pub const fn new ( ) -> String {
384385 String { vec : Vec :: new ( ) }
385386 }
386387
Original file line number Diff line number Diff line change 88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- // Test that Vec::new() can be used for constants
11+ // Test several functions can be used for constants
12+ // 1. Vec::new()
13+ // 2. String::new()
1214
1315#![ feature( const_vec_new) ]
16+ #![ feature( const_string_new) ]
1417
1518const MY_VEC : Vec < usize > = Vec :: new ( ) ;
1619
20+ const MY_STRING : String = String :: new ( ) ;
21+
1722pub fn main ( ) { }
You can’t perform that action at this time.
0 commit comments