Skip to content

Instantly share code, notes, and snippets.

@ooesili
Created February 11, 2018 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ooesili/761a817545fb929f5c2d593d533a30cd to your computer and use it in GitHub Desktop.
Save ooesili/761a817545fb929f5c2d593d533a30cd to your computer and use it in GitHub Desktop.
Rust channel sender error
error[E0308]: mismatched types
--> src/lib.rs:15:24
|
15 | self.chan.send(w);
| ^ expected type parameter, found a different type parameter
|
= note: expected type `A`
found type `W`
error: aborting due to previous error
use std::io;
use std::sync::mpsc;
// A trait like this is already defined in an external crate.
trait Send {
fn send<W: io::Write>(&self, w: W);
}
struct ChannelSender<A> {
chan: mpsc::SyncSender<A>,
}
impl<A> Send for ChannelSender<A> {
fn send<W: io::Write>(&self, w: W) {
self.chan.send(w);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment