]> git.lizzy.rs Git - rust.git/commit
Auto merge of #72717 - poliorcetics:try-from-int-to-nzint, r=dtolnay
authorbors <bors@rust-lang.org>
Thu, 25 Jun 2020 17:37:02 +0000 (17:37 +0000)
committerbors <bors@rust-lang.org>
Thu, 25 Jun 2020 17:37:02 +0000 (17:37 +0000)
commit50fc24d8a172a853b5dfe40702d6550e3b8562ba
tree76deb7c9dc12ef5ae3500c5292d23161da098de4
parent9f3c96b869b48ecd0bb556c6ad9cd603b4dacfb9
parent6c8d8d6a6055d19dc33cc8b33b082d17583a0e47
Auto merge of #72717 - poliorcetics:try-from-int-to-nzint, r=dtolnay

Add TryFrom<{int}> for NonZero{int}

Adds `TryFrom<{int}> for NonZero{int}`.

It uses the existing `NonZero{int}::new()` and `Option::ok_or()` functions, meaning the checks are not repeated.

I also added tests, I tried to follow the convention I saw in the test file.

I also used `#[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")]`, but I have no idea if the feature/version are correctly named or even correct.
src/libcore/convert/num.rs