Skip to content

Int-Uint conversion #837

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

erik-3milabs
Copy link
Contributor

This PR introduces Int::to_uint and Uint::to_int, allowing better conversion between these types.

@tarcieri
Copy link
Member

Hmm, I'm used to as_* and to_* with similar names being symmetric operations which provide borrowed and owned conversions

@erik-3milabs
Copy link
Contributor Author

Wdyt of

  • sticking with as_(u)int for the casting operation (i.e., similar to u32 as i32), and
  • using try_into_(u)int for the conversion operation, which may fail, hence the try_*

@erik-3milabs
Copy link
Contributor Author

erik-3milabs commented Jun 12, 2025

Hmmm, but try_into_(u)int is such a long name :(

And to_(u)int does match the to_odd and to_nz naming schemes 🤔

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