Skip to content

Instantly share code, notes, and snippets.

@Victory
Victory / gist:13faa35826067fced52d
Created December 23, 2014 23:02
why move stream
// this moves stream
fn send (&self,
mut stream: &mut BufferedStream<TcpStream>) {
let msg = match self.payload {
Payload::Text(ref s) => s.as_bytes(),
Payload::Binary(ref s) => s.as_slice(),
Payload::Empty => "".as_bytes(),
};
let length = msg.len() as u8;