rust-lang / reference

The Rust Reference
https://doc.rust-lang.org/nightly/reference/
Apache License 2.0
1.16k stars 451 forks source link

Document how extending int-to-ptr and ptr-to-int casts work #1496

Open Rua opened 3 weeks ago

Rua commented 3 weeks ago

Judging by the behaviour of Rust in this playground, these casts are treated the same as int-to-int casts, where the pointer is considered equivalent to usize. Casting i32 to usize will sign extend, casting usize to i128 will zero extend.