Closed VenusHu closed 6 years ago
You are getting that error because only your underlying Peer
struct implements the interface that you are needing. Arc<Peer>
is a different type altogether, and according to the compiler, does not implement that interface.
A way to work around this:
Solved it. The reason why I need to share the instance with other threads is that my instance needs to be both rpc client and server. I'm constructing a p2p system.
@thedodd thank you for help answering!
Absolutely.
Hi, I'm new to rust, so I have a problem bothering me, hoping to get help. I define a struct called Peer, wrapped it using Arc, then use a new thread to start PRC server:
then I get compile error:
So what's the correct way to write the code? Many thanks!