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

Infallible conversions from unsigned to larger-but-signed conversions #54

Open
morrisonlevi opened this issue Jan 19, 2023 · 2 comments

Comments

@morrisonlevi
Copy link

Specifically, I want the cases where unsigned value is one less than a platform fixed-width integer, eg:

impl From<u63> for i64 {} 
impl From<u31> for i32 {}  
impl From<u15> for i16 {}
impl From<u7> for i8 {}

But I suppose it can work for all width less than the ones listed too. Does this seem like a coherent feature that's general enough to add?

@JonathanWoollett-Light
Copy link

If you're interested, check out my overhaul project https://github.com/JonathanWoollett-Light/ux2 where this is implemented e.g. https://docs.rs/ux2/latest/ux2/struct.u2.html#impl-From%3Cu2%3E-for-i10.

@bbaldino
Copy link
Collaborator

bbaldino commented Mar 1, 2024

Sounds reasonable to me. I'll try and take a look at adding this.

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

3 participants