Skip to main content

format_speed

Function format_speed 

Source
pub fn format_speed(speed: f64, unit: &str) -> String
Expand description

Formats a speed value with a unit suffix.

The speed is formatted with 2 decimal places. If the speed is NaN or infinite, returns “N/A”.

§Arguments

  • speed - The speed value
  • unit - The unit suffix (e.g., “/s”, “/m”)

§Returns

A formatted string like “123.45/s” or “N/A”

§Examples

use qubit_clock::meter::format_speed;

assert_eq!(format_speed(123.456, "/s"), "123.46/s");
assert_eq!(format_speed(0.0, "/m"), "0.00/m");
assert_eq!(format_speed(f64::NAN, "/s"), "N/A");