@@ -65,14 +65,14 @@ But with this RFC, you can now write:
65
65
66
66
``` rust
67
67
const X : T = None ;
68
- const arr : [u32 ; 100 ] = [X ; 100 ];
68
+ const arr : [T ; 100 ] = [X ; 100 ];
69
69
```
70
70
71
71
or, if you wish to modify the array later:
72
72
73
73
``` rust
74
74
const X : T = None ;
75
- let mut arr = [x ; 100 ];
75
+ let mut arr = [X ; 100 ];
76
76
arr [0 ] = Some (Box :: new (1 ));
77
77
```
78
78
@@ -108,7 +108,10 @@ internally as:
108
108
109
109
``` rust
110
110
// This is the value to be repeated and typeof(X) the type it has.
111
+ // If a `VALUE` panics, it happens during compile time at this point
112
+ // and not later.
111
113
const X : typeof (X ) = VALUE ;
114
+
112
115
// N is the size of the array and how many times to repeat X.
113
116
const N : usize = SIZE ;
114
117
@@ -121,7 +124,7 @@ const N: usize = SIZE;
121
124
let mut iter = (& mut data [.. ]). into_iter ();
122
125
while let Some (elem ) = iter . next () {
123
126
// ptr::write does not run destructor of elem already in array.
124
- // Since X is const, it can not panic.
127
+ // Since X is const, it can not panic at this point .
125
128
ptr :: write (elem , X );
126
129
}
127
130
}
@@ -156,8 +159,4 @@ be `const`.
156
159
# Unresolved questions
157
160
[ unresolved ] : #unresolved-questions
158
161
159
- [ `drop_types_in_const` ] : https://github.com/rust-lang/rfcs/blob/master/text/1440-drop-types-in-const.md
160
-
161
- The relation to [ ` drop_types_in_const ` ] should be resolved during the RFC process.
162
- The soundness of the proposal should be verified.
163
- Other than that, there are no unresolved questions.
162
+ There are no unresolved questions.
0 commit comments