Update to rust 1.44.0 (#10585)
* Update rust 1.44.0 * Update rust nightly 1.46.0 * Update docs * Fix clippy errors * Compile all source code with stable and nightly * Add another note * script tweaks * Fix a test... * Add another workaround * Add hack * Increase timeout... * Revert "Add hack" This reverts commit 5960f087203be8792ec0728a6755288c317a2788. * Revert "Add another workaround" This reverts commit e14300d01ffd1b8e86e676662177545549b45c13. * Require nightly rustfmt and use older nightly a bit * Improve document a bit * Revert now not-existing clippy check...
This commit is contained in:
@ -40,10 +40,12 @@ pub fn years_as_slots(years: f64, tick_duration: &Duration, ticks_per_slot: u64)
|
||||
|
||||
/// From slots per year to slot duration
|
||||
pub fn slot_duration_from_slots_per_year(slots_per_year: f64) -> Duration {
|
||||
// Regarding division by zero potential below: for some reason, if Rust stores an `inf` f64 and
|
||||
// then converts it to a u64 on use, it always returns 0, as opposed to std::u64::MAX or any
|
||||
// other huge value
|
||||
let slot_in_ns = (SECONDS_PER_YEAR * 1_000_000_000.0) / slots_per_year;
|
||||
// Recently, rust changed from infinity as usize being zero to 2^64-1; ensure it's zero here
|
||||
let slot_in_ns = if slots_per_year != 0.0 {
|
||||
(SECONDS_PER_YEAR * 1_000_000_000.0) / slots_per_year
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
Duration::from_nanos(slot_in_ns as u64)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user