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