Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. trait Foo {
  2. fn foo() -> i32 where Self:Sized;
  3. }
  4.  
  5. type FooFunc<R> = dyn Fn() -> R;
  6.  
  7. struct S;
  8.  
  9. impl Foo for S {
  10. fn foo() -> i32 { 1 }
  11. }
  12.  
  13. fn gen<T:Foo>() {
  14. //let func : &dyn Fn() -> i32 = &T::foo; // works
  15. let func : &FooFunc<i32> = &T::foo; // doesn't work, but should be identical to the line above (???)
  16. println!("{}",func());
  17. }
  18.  
  19. fn main() {
  20. gen::<S>();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement