Skip to content

Conversation

@vlad20012
Copy link
Contributor

unsafe { mem::transmute::<i16, u16>(exp) } as u64 is equivalent to exp as u16 as u64, this can be verified with a simple program:

fn main() {
    for i in i16::MIN ..= i16::MAX {
        assert_eq!(
            unsafe { std::mem::transmute::<i16, u16>(i) } as u64,
            i as u16 as u64
        )
    }
}

`unsafe { mem::transmute::<i16, u16>(exp) } as u64`
 is equivalent to `exp as u16 as u64`, this can be
 verified with a simple program:

```rust
fn main() {
    for i in i16::MIN ..= i16::MAX {
        assert_eq!(
            unsafe { std::mem::transmute::<i16, u16>(i) } as u64,
            i as u16 as u64
        )
    }
}
```
@mbrubeck mbrubeck merged commit 76b11cd into reem:master Sep 14, 2021
@mbrubeck
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants