Created
June 19, 2014 04:21
-
-
Save retep998/fc8acc664cf43a9dab92 to your computer and use it in GitHub Desktop.
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
#![feature(phase, macro_rules)] | |
#[phase(plugin)] | |
extern crate green; | |
use std::collections::{HashMap, SmallIntMap}; | |
use std::comm::{Receiver, Sender}; | |
use std::io::{Acceptor, BufferedReader, BufferedWriter, BufReader, IoResult, Listener, MemWriter, TcpListener, TcpStream, stdin}; | |
use std::sync::{Arc, RWLock}; | |
type Opcode = u16; | |
type Id = u32; | |
green_start!(main) | |
fn main() { | |
let (send, recv) = channel::<Message>(); | |
spawn(proc() commands(send)); | |
loop {} | |
} | |
//If I get rid of this enum and use int instead it works | |
enum Message { | |
RemovePlayer(Id), | |
SendPacket(Id, Vec<u8>), | |
AddPlayer(TcpStream), | |
Shutdown, | |
} | |
fn commands(send: Sender<Message>) { | |
let mut cin = stdin(); | |
println!("This prints"); | |
for line in cin.lines() { | |
println!("This does not print?"); | |
let line = match line { | |
Ok(line) => line, | |
Err(_) => fail!("ERROR: Stdin failed. Give up all hope."), | |
}; | |
let line: String = line.as_slice().chars().map(|c| c.to_lowercase()).collect(); | |
println!("{}", line.as_bytes());//Commenting out this line also makes it work | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment