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

Allow for representing Option<uint> as an integer with an excluded sentinel value #14369

Closed
zwarich opened this issue May 23, 2014 · 4 comments
Closed

Comments

@zwarich
Copy link

zwarich commented May 23, 2014

We should have some way of using Option<uint> (or a moral equivalent) for integers with an excluded sentinel value, e.g. MovePathIndex in librustc. It's frustrating that Option isn't actually a zero-cost abstraction, forcing you to fall back to manually checking sentinel values.

@zwarich
Copy link
Author

zwarich commented May 23, 2014

This would require giving up one representable value, of course.

@huonw
Copy link
Member

huonw commented May 23, 2014

This should be an RFC... and it has already been filed: rust-lang/rfcs#41

@ben0x539
Copy link
Contributor

A problem here is that you take a mutable reference to that uint and now all arithmetic on it has to be checked to make sure you don't fall into the None value.

@steveklabnik
Copy link
Member

Closing in favor of that RFC.

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

No branches or pull requests

4 participants