Skip to content

Instantly share code, notes, and snippets.

@retep998
Created June 19, 2014 04:21
Show Gist options
  • Save retep998/fc8acc664cf43a9dab92 to your computer and use it in GitHub Desktop.
Save retep998/fc8acc664cf43a9dab92 to your computer and use it in GitHub Desktop.
#![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