1 An invalid cast was attempted.
3 Erroneous code examples:
7 x as Vec<u8>; // error: non-primitive cast: `u8` as `std::vec::Vec<u8>`
11 let v = core::ptr::null::<u8>(); // So here, `v` is a `*const u8`.
12 v as &u8; // error: non-primitive cast: `*const u8` as `&u8`
15 Only primitive types can be cast into each other. Examples:
21 let v = core::ptr::null::<u8>();
22 v as *const i8; // ok!
25 For more information about casts, take a look at the Type cast section in
26 [The Reference Book][1].
28 [1]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions