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

Fix addition overflow in AtomicPosition #406

Merged
merged 2 commits into from Mar 24, 2022
Merged

Conversation

arxanas
Copy link
Contributor

@arxanas arxanas commented Mar 18, 2022

Closes #405.

src/state.rs Outdated Show resolved Hide resolved
src/draw_target.rs Outdated Show resolved Hide resolved
The `Default` implementation was confusing to me. I would expect that `AtomicPosition::default() == AtomicPosition::default()` in all cases.
@arxanas
Copy link
Contributor Author

arxanas commented Mar 24, 2022

Sorry for the delay. Resolved by doing arithmetic in u128.

FWIW, I would advise avoiding the use of as altogether, for the reasons at https://gist.github.com/SimonSapin/550ada9ebedcd21c41cf4e95891e03d7#not-yet-deprecating-the-as-keyword

@djc djc merged commit 647a1f8 into console-rs:main Mar 24, 2022
@djc
Copy link
Collaborator

djc commented Mar 24, 2022

That discussion is pretty old at this point, though. Here's a more recent one:

https://internals.rust-lang.org/t/lets-deprecate-as-for-lossy-numeric-casts/16283/45

Note that this talks about deprecating as for lossy casts, which is not what we're doing here. (There's technically still the risk of the type on the operand changing to something that does result in a lossy cast, but I feel like in this context that risk is not so large.)

@arxanas arxanas deleted the atomic-position branch March 24, 2022 04:58
@arxanas
Copy link
Contributor Author

arxanas commented Mar 26, 2022

@djc Thanks for merging. Please let me know when there's another release/pre-release so that I can publish a version of my package which depends on indicatif to crates.io.

@djc
Copy link
Collaborator

djc commented Mar 28, 2022

I've published rc10.

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.

Panic in AtomicPosition::allow
2 participants