SHARE
TWEET

Untitled

a guest Jul 16th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pub enum TmqMessage  {
  2.     Single(zmq::Message),
  3.     MultiPart(Vec<zmq::Message>)
  4. }
  5.  
  6.  
  7. // I can have one or the other, but not both
  8.  
  9. impl From<zmq::Message> for TmqMessage {
  10.     fn from(msg: zmq::Message) -> Self {
  11.         TmqMessage::Single(msg)
  12.     }
  13. }
  14.  
  15. impl<I: Iterator<Item=zmq::Message>> From<I> for TmqMessage {
  16.     fn from(msgs: I) -> Self {
  17.         TmqMessage::MultiPart(msgs.collect())
  18.     }
  19. }
  20.  
  21. /* Error from compiler:
  22.  
  23. error[E0119]: conflicting implementations of trait `std::convert::From<zmq::Message>` for type `poll::TmqMessage`:
  24.   --> src/poll.rs:41:1
  25.    |
  26. 35 | impl From<zmq::Message> for TmqMessage {
  27.    | -------------------------------------- first implementation here
  28. ...
  29. 41 | impl<I: Iterator<Item=zmq::Message>> From<I> for TmqMessage {
  30.    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `poll::TmqMessage`
  31.    |
  32.    = note: upstream crates may add new impl of trait `std::iter::Iterator` for type `zmq::Message` in future versions
  33.  
  34. error: aborting due to previous error
  35.  
  36. For more information about this error, try `rustc --explain E0119`.
  37. error: Could not compile `tmq`.
  38.  
  39.  
  40. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top