Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Foo {
- fn foo() -> i32 where Self:Sized;
- }
- type FooFunc<R> = dyn Fn() -> R;
- struct S;
- impl Foo for S {
- fn foo() -> i32 { 1 }
- }
- fn gen<T:Foo>() {
- //let func : &dyn Fn() -> i32 = &T::foo; // works
- let func : &FooFunc<i32> = &T::foo; // doesn't work, but should be identical to the line above (???)
- println!("{}",func());
- }
- fn main() {
- gen::<S>();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement