]> git.lizzy.rs Git - rust.git/blob - tests/ui/where-clauses/where-clauses.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / where-clauses / where-clauses.rs
1 // run-pass
2 trait Equal {
3     fn equal(&self, other: &Self) -> bool;
4     fn equals<T,U>(&self, this: &T, that: &T, x: &U, y: &U) -> bool
5             where T: Eq, U: Eq;
6 }
7
8 impl<T> Equal for T where T: Eq {
9     fn equal(&self, other: &T) -> bool {
10         self == other
11     }
12     fn equals<U,X>(&self, this: &U, other: &U, x: &X, y: &X) -> bool
13             where U: Eq, X: Eq {
14         this == other && x == y
15     }
16 }
17
18 fn equal<T>(x: &T, y: &T) -> bool where T: Eq {
19     x == y
20 }
21
22 fn main() {
23     println!("{}", equal(&1, &2));
24     println!("{}", equal(&1, &1));
25     println!("{}", "hello".equal(&"hello"));
26     println!("{}", "hello".equals::<isize,&str>(&1, &1, &"foo", &"bar"));
27 }