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

From<i32> for SwapInterval should be panic-less TryFrom<i32> implementation #1311

Open
KisaragiEffective opened this issue Jun 1, 2023 · 2 comments · May be fixed by #1413
Open

From<i32> for SwapInterval should be panic-less TryFrom<i32> implementation #1311

KisaragiEffective opened this issue Jun 1, 2023 · 2 comments · May be fixed by #1413

Comments

@KisaragiEffective
Copy link

Hi,

I've found that your implementation of From<i32> for SwapInterval panics if the given value is out of range. However, From trait seems not intended to be used with panic; I would like to purpose replace it with TryFrom<i32> implementation (this purpose is a breaking change).

@Cobrand
Copy link
Member

Cobrand commented Jun 1, 2023

Good idea, this functionality was added before TryFrom was introduced, this is why it was made that way.

@KisaragiEffective
Copy link
Author

I cloudn't find your MSRV requirement, so it may be wise to introduce failable_conversion feature (not turned on by default) and deprecate the impl when it is opted-in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants