1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
use std::f64; /// Calculates Pythagoras. /// #Examples /// ``` /// let a = 3; /// let b = 4; /// let c = pythagoras::theorem(a, b); /// assert_eq!(5f64, c); /// ``` pub fn theorem<T: Into<f64>>(a: T, b: T) -> f64 { let c: f64 = a.into().powi(2) + b.into().powi(2); return c.sqrt(); }