Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub fn update(&mut self, event: &mut ClientEvent) {
- let mut buffer = [0u8;1024];
- let mut first = true;
- loop {
- match self.stream.read(&mut buffer) {
- Ok(0) if first |
- Err(ref e) if e.kind() == ::std::io::ErrorKind::WouldBlock && !first => {
- println!("First read resulted in no bytes");
- break;
- },
- Ok(length) => {
- first = false;
- println!("Read {} bytes: {:?}", length, ::std::str::from_utf8(&buffer[0..length]));
- self.read_buffer.extend_from_slice(&buffer[0..length]);
- },
- Err(e) => {
- println!("Could not read: {} ({:?})", e, e.kind());
- break;
- }
- };
- }
- }
- /*
- error: expected expression, found keyword `ref`
- --> src/client.rs:41:21
- |
- 41 | Err(ref e) if e.kind() == ::std::io::ErrorKind::WouldBlock && !first => {
- | ^^^
- error: expected one of `)`, `.`, `<`, `=>`, `?`, `break`, `continue`, `false`, `for`, `if`, `loop`, `match`, `move`, `return`, `true`, `unsafe`, `while`, or an operator, found `ref`
- --> src/client.rs:41:21
- |
- 41 | Err(ref e) if e.kind() == ::std::io::ErrorKind::WouldBlock && !first => {
- | ^^^ expected one of 18 possible tokens here
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement