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

Add {f32,f64}::approx_unchecked_to<Int> unsafe methods #66841

Merged
merged 3 commits into from
Dec 7, 2019

Commits on Dec 6, 2019

  1. Configuration menu
    Copy the full SHA
    f442797 View commit details
    Browse the repository at this point in the history
  2. Add {f32,f64}::approx_unchecked_to<Int> unsafe methods

    As discussed in rust-lang#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.
    SimonSapin committed Dec 6, 2019
    Configuration menu
    Copy the full SHA
    cba479f View commit details
    Browse the repository at this point in the history
  3. Move numeric From and TryFrom impls to libcore/convert/num.rs

    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.
    SimonSapin committed Dec 6, 2019
    Configuration menu
    Copy the full SHA
    a213ff8 View commit details
    Browse the repository at this point in the history