Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate num_traits;
- use num_traits::Num;
- use num::cast::AsPrimitive;
- fn my_fn<T>(t: T, t2: i8) -> u32
- where T: Num + PartialEq + Copy + 'static,
- i8: AsPrimitive<T>,
- {
- if t == t2.as_() {
- 0
- } else {
- 3
- }
- }
- #[test]
- fn test_t() {
- let t: u32 = 32;
- assert_eq!(my_fn(t, 3), 3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement