Update operator-expr.md

This commit is contained in:
Joshua Liebow-Feeser 2023-10-25 21:43:21 -07:00 committed by GitHub
parent ed4811da2d
commit b3217718e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -480,12 +480,15 @@ assert_eq!(values[1], 3);
#### Slice DST pointer to pointer cast
For slice types like `[T]` and `[U]`, the raw pointer types `*const [T]`, `*mut [T]`, `*const [U]`, and `*mut [U]`
encode the number of elements in this slice. Casts between these raw pointer types
preserve the number of elements. Note that, as a consequence, such casts do *not*
necessarily preserve the size of the pointer's referent (e.g., casting `*const [u16]`
to `*const [u8]` will result in a raw pointer which refers to an object of half the size
of the original).
For slice types like `[T]` and `[U]`, the raw pointer types `*const [T]`, `*mut [T]`,
`*const [U]`, and `*mut [U]` encode the number of elements in this slice. Casts between
these raw pointer types preserve the number of elements. Note that, as a consequence,
such casts do *not* necessarily preserve the size of the pointer's referent (e.g.,
casting `*const [u16]` to `*const [u8]` will result in a raw pointer which refers to an
object of half the size of the original). The same holds for `str` and any compound type
whose unsized tail is a slice type, such as struct `Foo(i32, [u8])` or `(u64, Foo)`.
## Assignment expressions