Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait T<T> {
- fn test(t: T) -> bool;
- }
- struct Test;
- impl T<i32> for Test {
- fn test(t: i32) -> bool {
- println!("i32 impl!");
- t % 2 == 0
- }
- }
- impl T<bool> for Test {
- fn test(t: bool) -> bool {
- println!("bool impl!");
- t
- }
- }
- fn main() {
- let t1 = Test::test(2);
- let t2 = Test::test(false);
- println!("{T1}, {T2}", T1 = t1, T2 = t2)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement