Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn foo_i32(x: i32, y: i32) -> i32 {
- x * y
- }
- use std::ops::Mul;
- fn foo<T>(x: T, y: T) -> T where T: Mul<Output = T> {
- x * y
- }
- fn main() {
- println!("i32: {}", foo_i32(3, 2));
- println!("i32: {}", foo(3, 2));
- println!("i32: {}", foo(3.5, 2.5));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement