Trait Round

Source
pub trait Round {
    // Required method
    const fn round(self) -> Self;
}
Expand description

✅ Rounds the number to the nearest integer, away from zero on tie. If rounding would cause an overflow, returns the nearest representable result instead.

§Examples

  • ...123.4 -> ...123
  • ...123.5 -> ...124
  • ...123.6 -> ...124
  • ...123.6 -> ...123 if ...124 is not representable.

§Panics

This function never panics.

Required Methods§

Source

const fn round(self) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§