erickt / rust-zmq

Rust zeromq bindings.
Apache License 2.0
900 stars 194 forks source link

Examples failed to build #172

Closed adfaure closed 7 years ago

adfaure commented 7 years ago

Hello, I try to begin to work with rust-zmq, so I wanted to try your example. I create a simple project and I copied one examples into my main. Unfortunately they are all failing to build.

I tried for example rust-zmq/examples/msgsend/main.rs. Here the output I get:

error[E0308]: mismatched types
  --> src/main.rs:13:26
   |
13 |         pull_socket.recv(&mut msg, 0).unwrap();
   |                          ^^^^^^^^ expected struct `zmq::Message`, found enum `std::result::Result`
   |
   = note: expected type `&mut zmq::Message`
   = note:    found type `&mut std::result::Result<zmq::Message, zmq::Error>`

error: no method named `as_str` found for type `std::result::Result<zmq::Message, zmq::Error>` in the current scope
  --> src/main.rs:14:21
   |
14 |         let s = msg.as_str().unwrap();
   |                     ^^^^^^

error[E0308]: mismatched types
  --> src/main.rs:22:22
   |
22 |     push_socket.send(&count.to_string(), 0).unwrap();
   |                      ^^^^^^^^^^^^^^^^^^ expected slice, found struct `std::string::String`
   |
   = note: expected type `&[u8]`
   = note:    found type `&std::string::String`

error[E0308]: mismatched types
  --> src/main.rs:54:26
   |
54 |         push_socket.send(&100.to_string(), 0).unwrap();
   |                          ^^^^^^^^^^^^^^^^ expected slice, found struct `std::string::String`
   |
   = note: expected type `&[u8]`
   = note:    found type `&std::string::String`

error[E0308]: mismatched types
  --> src/main.rs:58:22
   |
58 |     push_socket.send("", 0).unwrap();
   |                      ^^ expected slice, found str
   |
   = note: expected type `&[u8]`
   = note:    found type `&'static str`

error: aborting due to 5 previous errors

I am pretty new to rust, do I missed something ? Many thanks for your help.