@@ -307,7 +307,8 @@ fn average(values: &[f64]) -> f64 {
307
307
308
308
` as ` can be used to explicitly perform [ coercions] ( ../type-coercions.md ) , as well as the following additional casts.
309
309
Any cast that does not fit either a coercion rule or an entry in the table is a compiler error.
310
- Here ` *T ` means either ` *const T ` or ` *mut T ` .
310
+ Here ` *T ` means either ` *const T ` or ` *mut T ` . ` m ` stands for optional ` mut ` in
311
+ reference types and ` mut ` or ` const ` in pointer types.
311
312
312
313
| Type of ` e ` | ` U ` | Cast performed by ` e as U ` |
313
314
| -----------------------| -----------------------| ----------------------------------|
@@ -318,17 +319,21 @@ Here `*T` means either `*const T` or `*mut T`.
318
319
| ` *T ` | ` *V ` where ` V: Sized ` \* | Pointer to pointer cast |
319
320
| ` *T ` where ` T: Sized ` | Integer type | Pointer to address cast |
320
321
| Integer type | ` *V ` where ` V: Sized ` | Address to pointer cast |
321
- | ` &[T; n] ` | ` *const T ` | Array to pointer cast |
322
+ | ` &m₁ T ` | ` *m₂ T ` \*\* | Reference to pointer cast |
323
+ | ` &m₁ [T; n] ` | ` *m₂ T ` \*\* | Array to pointer cast |
322
324
| [ Function item] | [ Function pointer] | Function item to function pointer cast |
323
325
| [ Function item] | ` *V ` where ` V: Sized ` | Function item to pointer cast |
324
326
| [ Function item] | Integer | Function item to address cast |
325
327
| [ Function pointer] | ` *V ` where ` V: Sized ` | Function pointer to pointer cast |
326
328
| [ Function pointer] | Integer | Function pointer to address cast |
327
- | Closure \*\* | Function pointer | Closure to function pointer cast |
329
+ | Closure \*\*\* | Function pointer | Closure to function pointer cast |
328
330
329
331
\* or ` T ` and ` V ` are compatible unsized types, e.g., both slices, both the same trait object.
330
332
331
- \*\* only for closures that do not capture (close over) any local variables
333
+ \*\* only when ` m₁ ` is ` mut ` or ` m₂ ` is ` const ` . Casting ` mut ` reference to
334
+ ` const ` pointer is allowed.
335
+
336
+ \*\*\* only for closures that do not capture (close over) any local variables
332
337
333
338
### Semantics
334
339
0 commit comments