Skip to content

Commit b6089dd

Browse files
authored
Update operator-expr.md
1 parent 8ce1106 commit b6089dd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/expressions/operator-expr.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,16 @@ unsafe {
478478
assert_eq!(values[1], 3);
479479
```
480480

481+
#### Slice DST pointer to pointer cast
482+
483+
When `T` and `U` are both "slice DSTs" - ie, slice types or types whose trailing field
484+
is a slice type - the raw pointer types `*const T`, `*mut T`, `*const U`, and `*mut U`
485+
encode the number of elements in this slice. Casts between these raw pointer types
486+
preserve the number of elements. Note that, as a consequence, such casts do *not*
487+
necessarily preserve the size of the pointer's referent (e.g., casting `*const [u16]`
488+
to `*const [u8]` will result in a raw pointer which refers to an object of half the size
489+
of the original).
490+
481491
## Assignment expressions
482492

483493
> **<sup>Syntax</sup>**\

0 commit comments

Comments
 (0)