Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop unsafe blocks from common.rs #61

Merged
merged 1 commit into from
Aug 31, 2019

Conversation

Shnatsel
Copy link
Contributor

Sadly there is no idiomatic way to convert a number to enum. This version is more verbose, but lets the compiler reason about safety, and compiles to the exact same assembly (verified with cargo-asm).

This could also be accomplished with a procedural macro instead of boilerplate, but that sounds like an overkill. Further discussion on the topic: https://internals.rust-lang.org/t/pre-rfc-enum-from-integer/6348/22

Sadly there is no idiomatic way to convert a number to enum. This version is more verbose, but lets the compiler reason about safety, and compiles to the exact same assembly (verified with `cargo-asm`).
Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's reasonable.

@JohnTitor JohnTitor merged commit 1ccca65 into image-rs:master Aug 31, 2019
@HeroicKatora
Copy link
Member

Good reminder. We may want to organize fortnightly triage to not let similar PRs stall for too long.

@Shnatsel Shnatsel deleted the drop-transmutes branch August 31, 2019 20:22
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.

3 participants