You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/expressions/operator-expr.md
+7-7
Original file line number
Diff line number
Diff line change
@@ -460,29 +460,29 @@ reference types and `mut` or `const` in pointer types.
460
460
| Enumeration | Integer type |[Enum cast][expr.as.enum]|
461
461
|`bool` or `char`| Integer type |[Primitive to integer cast][expr.as.bool-char-as-int]|
462
462
|`u8`|`char`|[`u8` to `char` cast][expr.as.u8-as-char]|
463
-
|`*T`|`*V`[^1]|[Pointer to pointer cast][expr.as.pointer]|
463
+
|`*T`|`*V`[^meta-compat]|[Pointer to pointer cast][expr.as.pointer]|
464
464
|`*T` where `T: Sized`| Integer type |[Pointer to address cast][expr.as.pointer-as-int]|
465
465
| Integer type |`*V` where `V: Sized`|[Address to pointer cast][expr.as.int-as-pointer]|
466
-
|`&m₁ [T; n]`|`*m₂ T`[^2]| Array to pointer cast |
467
-
|`*m₁ [T; n]`|`*m₂ T`[^2]| Array to pointer cast |
466
+
|`&m₁ [T; n]`|`*m₂ T`[^lessmut]| Array to pointer cast |
467
+
|`*m₁ [T; n]`|`*m₂ T`[^lessmut]| Array to pointer cast |
468
468
|[Function item]|[Function pointer]| Function item to function pointer cast |
469
469
|[Function item]|`*V` where `V: Sized`| Function item to pointer cast |
470
470
|[Function item]| Integer | Function item to address cast |
471
471
|[Function pointer]|`*V` where `V: Sized`| Function pointer to pointer cast |
472
472
|[Function pointer]| Integer | Function pointer to address cast |
473
-
| Closure [^3]| Function pointer | Closure to function pointer cast |
473
+
| Closure [^no-capture]| Function pointer | Closure to function pointer cast |
474
474
475
-
[^1]: where `T` and `V` have compatible metadata:
475
+
[^meta-compat]: where `T` and `V` have compatible metadata:
476
476
*`V: Sized`, or
477
477
* Both slice metadata (`*[u16]` -> `*[u8]`, `*str` -> `*(u8, [u32])`), or
478
478
* Both the same trait object metadata, modulo dropping auto traits (`*dyn Debug` -> `*(u16, dyn Debug)`, `*dyn Debug + Send` -> `*dyn Debug`)
479
479
***Note**: *adding* auto traits is only allowed if the principal trait has the auto trait as a super trait (given `trait T: Send {}`, `*dyn T` -> `*dyn T + Send` is valid, but `*dyn Debug` -> `*dyn Debug + Send` is not)
480
480
***Note**: Generics (including lifetimes) must match (`*dyn T<'a, A>` -> `*dyn T<'b, B>` requires `'a = 'b` and `A = B`)
481
481
482
-
[^2]: only when `m₁` is `mut` or `m₂` is `const`. Casting `mut` reference/pointer to
482
+
[^lessmut]: only when `m₁` is `mut` or `m₂` is `const`. Casting `mut` reference/pointer to
483
483
`const` pointer is allowed.
484
484
485
-
[^3]: only for closures that do not capture (close over) any local variables can be casted to function pointers.
485
+
[^no-capture]: only for closures that do not capture (close over) any local variables can be casted to function pointers.
0 commit comments