]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | #[allow(clippy::unnecessary_operation)] |
2 | #[allow(clippy::implicit_clone)] | |
3 | ||
4 | fn main() { | |
5 | let x = &Baz; | |
6 | let y = &Baz; | |
7 | y.to_owned() == *x; | |
8 | ||
9 | let x = &&Baz; | |
10 | let y = &Baz; | |
11 | y.to_owned() == **x; | |
12 | } | |
13 | ||
14 | struct Foo; | |
15 | ||
16 | impl PartialEq for Foo { | |
17 | fn eq(&self, other: &Self) -> bool { | |
18 | self.to_owned() == *other | |
19 | } | |
20 | } | |
21 | ||
22 | impl ToOwned for Foo { | |
23 | type Owned = Bar; | |
24 | fn to_owned(&self) -> Bar { | |
25 | Bar | |
26 | } | |
27 | } | |
28 | ||
29 | #[derive(PartialEq)] | |
30 | struct Baz; | |
31 | ||
32 | impl ToOwned for Baz { | |
33 | type Owned = Baz; | |
34 | fn to_owned(&self) -> Baz { | |
35 | Baz | |
36 | } | |
37 | } | |
38 | ||
39 | #[derive(PartialEq)] | |
40 | struct Bar; | |
41 | ||
42 | impl PartialEq<Foo> for Bar { | |
43 | fn eq(&self, _: &Foo) -> bool { | |
44 | true | |
45 | } | |
46 | } | |
47 | ||
48 | impl std::borrow::Borrow<Foo> for Bar { | |
49 | fn borrow(&self) -> &Foo { | |
50 | static FOO: Foo = Foo; | |
51 | &FOO | |
52 | } | |
53 | } |