Created
February 11, 2018 21:28
-
-
Save ooesili/761a817545fb929f5c2d593d533a30cd to your computer and use it in GitHub Desktop.
Rust channel sender error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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