Rust Lifetimes with mpsc::Sender<T<'a>> and threads
<p>I'm creating a multi-threaded application where I create a receiving channel and a structure to hold the sending channel (to be used later by the implementation). However, the type I'm sending through the channel has a lifetime specification. This type is <code>websocket::message:Message</code>
from the rusts-weboscket library. Because of this specification, rust can't seem to correctly infer lifetimes when it gets passed through a thread.</p>

<p>Here's a rust playground example of this error: 
<a href="https://play.rust-lang.org/?gist=7e37547d1c811185654f10a6a461e1ef&amp;version=stable&amp;backtrace=1" rel="nofollow">https://play.rust-lang.org/?gist=7e37547d1c811185654f10a6a461e1ef&amp;version=stable&amp;backtrace=1</a></p>

<p>Now, I have tried using crossbeam to scope the lifetime, and this seems to solve that immediate issue, but in practically just delegates the lifetime specification issue somewhere else.</p>

<p>In my code I get the error:</p>

<pre><code>   $ cargo check
   Compiling rump v0.1.0 (file:///home/alainh/UPenn/CIS198/Rump)
transport.rs:200:42: 200:57 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements [E0495]
transport.rs:200         self.sender.send(self.serializer.encode(message));
                                                          ^~~~~~~~~~~~~~~
transport.rs:199:5: 202:6 help: consider using an explicit lifetime parameter as shown: fn send&lt;T: Encodable&gt;(&amp;'a mut self, message: &amp;T) -&gt; WampResult&lt;()&gt;
transport.rs:199     fn send&lt;T: Encodable&gt;(&amp;mut self, message: &amp;T) -&gt; WampResult&lt;()&gt; {
transport.rs:200         self.sender.send(self.serializer.encode(message));
transport.rs:201         Ok(())
transport.rs:202     }
error: aborting due to previous error
Could not compile `rump`.
</code></pre>

<p>The line in question is this one:
<a href="https://github.com/aehernandez/Rump/blob/ad717c7ef11857e94d0e1c02539667c8034676c4/src/transport.rs#L199" rel="nofollow">https://github.com/aehernandez/Rump/blob/ad717c7ef11857e94d0e1c02539667c8034676c4/src/transport.rs#L199</a></p>

<p>At this point I'm unsure how to exactly solve this lifetime issue. I don't want to keep delegating it somewhere else. Is there a good solution to this?</p>