12 releases
Uses old Rust 2015
0.2.4 | Feb 19, 2018 |
---|---|
0.2.3 | Feb 18, 2018 |
0.2.2 | Jan 26, 2018 |
0.2.1 | Dec 17, 2017 |
0.1.0 | Aug 17, 2017 |
#2310 in Algorithms
32 downloads per month
Used in number_easing
80KB
2.5K
SLoC
rs-number_traits
number traits
extern crate number_traits;
use number_traits::{Num, Sqrt};
fn add<T>(a: T, b: T) -> T
where T: Num,
{
a + b
}
fn sqrt<T>(x: T) -> <T as Sqrt>::Output
where T: Sqrt,
{
x.sqrt()
}
fn main() {
assert_eq!(add(2, 2), 4);
assert_eq!(add(2.0, 2.0), 4);
assert_eq!(sqrt(4), 2);
assert_eq!(sqrt(4.0), 2);
}
Dependencies
~44KB