@ -19,47 +19,11 @@ very easily lead to terrible things. However the act of creating the pointer
itself is safe, because actually using a raw pointer is already marked as
itself is safe, because actually using a raw pointer is already marked as
`unsafe`.
`unsafe`.
Here's an exhaustive list of all the true casts. For brevity, we will use `*`
Note that lengths are not adjusted when casting raw slices; `*const [u16] as *const [u8]` creates a slice that only includes half of the original memory.
to denote either a `*const` or `*mut`, and `integer` to denote any integral
primitive:
* `*T as *U` where `T, U: Sized`
Casting is not transitive, that is, even if `e as U1 as U2` is a valid expression, `e as U2` is not necessarily so.
* `*T as *U` TODO: explain unsized situation
* `*T as integer`
* `integer as *T`
* `number as number`
* `field-less enum as integer`
* `bool as integer`
* `char as integer`
* `u8 as char`
* `&[T; n] as *const T`
* `fn as *T` where `T: Sized`
* `fn as integer`
Note that lengths are not adjusted when casting raw slices -
You can find an exhaustive list of [all the true casts][cast list] and [casting semantics][semantics list] on the reference.
`*const [u16] as *const [u8]` creates a slice that only includes
half of the original memory.
Casting is not transitive, that is, even if `e as U1 as U2` is a valid