Skip to content

Commit 5646632

Browse files
author
arielb1
committed
Changes for raw pointer casts
1 parent e233f8d commit 5646632

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

text/0401-coercions.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,12 @@ following holds:
335335

336336
where `&.T` and `*T` are references of either mutability,
337337
and where unsize_kind(`T`) is the kind of the unsize info
338-
in `T` - a vtable or a length (or `()` if `T: Sized`).
338+
in `T` - the vtable for a trait definition (e.g. `fmt::Display` or
339+
`Iterator`, not `Iterator<Item=u8>`) or a length (or `()` if `T: Sized`).
340+
341+
Note that lengths are not adjusted when casting raw slices -
342+
`T: *const [u16] as *const [u8]` creates a slice that only includes
343+
half of the original memory.
339344

340345
Casting is not transitive, that is, even if `e as U1 as U2` is a valid
341346
expression, `e as U2` is not necessarily so (in fact it will only be valid if

0 commit comments

Comments
 (0)