SHARE
TWEET

Untitled

a guest Aug 21st, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top