]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/issue-18412.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / traits / issue-18412.rs
1 // run-pass
2 // Test that non-static methods can be assigned to local variables as
3 // function pointers.
4
5
6 trait Foo {
7     fn foo(&self) -> usize;
8 }
9
10 struct A(usize);
11
12 impl A {
13     fn bar(&self) -> usize { self.0 }
14 }
15
16 impl Foo for A {
17     fn foo(&self) -> usize { self.bar() }
18 }
19
20 fn main() {
21     let f = A::bar;
22     let g = Foo::foo;
23     let a = A(42);
24
25     assert_eq!(f(&a), g(&a));
26 }