use syunit::*; use syunit::metric::*; pub fn prompt(msg : &str, default_opt : Option) -> T { let mut input_string = String::new(); loop { print!("{}", msg); std::io::Write::flush(&mut std::io::stdout()).unwrap(); std::io::stdin().read_line(&mut input_string).unwrap(); if let Ok(res) = T::from_str(input_string.trim()) { return res; } else { if let Some(default) = default_opt { return default; } else { println!("Bad input for type!"); } } } } fn main() { // Kin3 // let jolt : MMPerSecond3 = prompt("Enter jolt: ", Some(MMPerSecond3(1.0))); // let accel : MMPerSecond2 = prompt("Enter acceleration: ", Some(MMPerSecond2(1.0))); // let vel : MMPerSecond = prompt("Enter velocity: ", Some(MMPerSecond(1.0))); // let dist : Millimeters = prompt("Enter relative distance: ", Some(Millimeters(1.0))); // println!("Result: {}", sykin::kin3::time_for_distance::(dist, vel, accel, jolt)); // TODO: Add more calculations let distance = Millimeters(6.0); let velocity = MMPerSecond(11.0); let acceleration = MMPerSecond2(-12.0); let jolt = MMPerSecond3(6.0); assert_eq!(sykin::kin3::time_for_distance::(distance, velocity, acceleration, jolt), Seconds(1.0)); }