about summary refs log tree commit diff
path: root/src/libcore/convert/num.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-487/+0
2020-06-30Deny unsafe ops in unsafe fns, part 6LeSeulArtichaut-2/+0
And final part!!!
2020-06-30Deny unsafe ops in unsafe fns, part 1LeSeulArtichaut-1/+4
2020-06-25Auto merge of #72717 - poliorcetics:try-from-int-to-nzint, r=dtolnaybors-0/+39
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.
2020-06-10Migrate to numeric associated constsLzu Tao-3/+3
2020-06-08Added implementations for NonZero(U|I)sizeAlexis Bourget-0/+2
2020-05-29Added implementations for TryFrom<{int}> for NonZero{int}Alexis Bourget-0/+37
2020-04-25Bump bootstrap compilerMark Rousskov-8/+1
2020-03-29Stabilize float::to_int_uncheckedMark Rousskov-4/+11
This renames and stabilizes unsafe floating point to integer casts, which are intended to be the substitute for the currently unsound `as` behavior, once that changes to safe-but-slower saturating casts.
2020-01-06Use Self instead of $typeLzu Tao-14/+14
2019-12-18Propagate cfg bootstrapMark Rousskov-2/+0
2019-12-08move from non zero impls to `libcore/convert/num.rs`Peter-0/+449
2019-12-06Move numeric `From` and `TryFrom` impls to `libcore/convert/num.rs`Simon Sapin-0/+331
This makes `libcore/num/mod.rs` slightly smaller. It’s still 4911 lines and not easy to navigate. This doesn’t change any public API.
2019-12-06Add `{f32,f64}::approx_unchecked_to<Int>` unsafe methodsSimon Sapin-0/+38
As discussed in https://github.com/rust-lang/rust/issues/10184 Currently, casting a floating point number to an integer with `as` is Undefined Behavior if the value is out of range. `-Z saturating-float-casts` fixes this soundness hole by making `as` “saturate” to the maximum or minimum value of the integer type (or zero for `NaN`), but has measurable negative performance impact in some benchmarks. There is some consensus in that thread for enabling saturation by default anyway, but provide an `unsafe fn` alternative for users who know through some other mean that their values are in range.