I have the following code:
extern crate futures; // 0.1.24 use futures::Future; use std::io; struct Context; pub trait MyTrait { fn receive(context: Context) -> Future<Item = (), Error = io::Error>; } pub struct MyStruct { my_trait: MyTrait, } When I try to compile it I get the error message:
error[E0038]: the trait `MyTrait` cannot be made into an object --> src/lib.rs:13:5 | 13 | my_trait: MyTrait, | ^^^^^^^^^^^^^^^^^ the trait `MyTrait` cannot be made into an object | = note: method `receive` has no receiver I think I know why it happens, but how do I refer to the trait from the struct? Is it possible? Maybe there are other ways to implement the same behavior?