File tree 3 files changed +9
-2
lines changed
3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 125
125
#![ feature( inclusive_range_methods) ]
126
126
#![ cfg_attr( stage0, feature( generic_param_attrs) ) ]
127
127
#![ feature( rustc_const_unstable) ]
128
+ #![ feature( const_vec_new) ]
128
129
129
130
#![ cfg_attr( not( test) , feature( fn_traits, i128 ) ) ]
130
131
#![ cfg_attr( test, feature( test) ) ]
Original file line number Diff line number Diff line change @@ -380,7 +380,8 @@ impl String {
380
380
/// ```
381
381
#[ inline]
382
382
#[ 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 {
384
385
String { vec : Vec :: new ( ) }
385
386
}
386
387
Original file line number Diff line number Diff line change 8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
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()
12
14
13
15
#![ feature( const_vec_new) ]
16
+ #![ feature( const_string_new) ]
14
17
15
18
const MY_VEC : Vec < usize > = Vec :: new ( ) ;
16
19
20
+ const MY_STRING : String = String :: new ( ) ;
21
+
17
22
pub fn main ( ) { }
You can’t perform that action at this time.
0 commit comments