Semantic line wrapping.

This commit is contained in:
Eric Huss 2024-02-21 13:20:15 -08:00
parent 72fb626596
commit 97c9ad16e5
1 changed files with 8 additions and 11 deletions

View File

@ -483,18 +483,15 @@ assert_eq!(values[1], 3);
`*const T` / `*mut T` can be cast to `*const U` / `*mut U` with the following behavior:
- If `T` and `U` are both sized, the pointer is returned unchanged.
- If `T` and `U` are both unsized, the pointer is also returned unchanged. In particular,
the metadata is preserved exactly.
- If `T` and `U` are both unsized, the pointer is also returned unchanged.
In particular, the metadata is preserved exactly.
For instance, a cast from `*const [T]` to `*const [U]` preserves 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)`.
- If `T` is unsized and `U` is sized, the cast discards all metadata that
completes the wide pointer `T` and produces a thin pointer `U` consisting
of the data part of the unsized pointer.
For instance, a cast from `*const [T]` to `*const [U]` preserves 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)`.
- If `T` is unsized and `U` is sized, the cast discards all metadata that completes the wide pointer `T` and produces a thin pointer `U` consisting of the data part of the unsized pointer.
## Assignment expressions