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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
namespace Trees | |
{ | |
public class CompilableTree<TKey, TValue> | |
{ | |
protected readonly CompilableTree<TKey, TValue> _parent; |
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
use std::io::net::ip::{Ipv4Addr, SocketAddr}; | |
use std::io::net::tcp::{TcpListener, TcpStream}; | |
use std::io::{Acceptor, Listener, IoResult}; | |
struct Client { | |
stream: TcpStream | |
} | |
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
extern crate time; | |
use std::io::{Listener, Acceptor}; | |
use std::io::net::tcp::{TcpListener}; | |
use std::io::net::ip::{SocketAddr, Ipv4Addr}; | |
use std::io::timer; | |
static TICK_TIME: i32 = 60; //ms | |
fn tick(last_tick: &mut i32) { |
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
/// # Example | |
/// | |
/// ```rust | |
/// fn main() { | |
/// let mut tree = Tree::<char,String>::new(); | |
/// tree.insert_recursively(&vec!('H', 'C'), "HandleHelloConnectMessage".into_string()); | |
/// tree.insert_recursively(&vec!('H', 'G'), "HandleHelloGameMessage".into_string()); | |
/// | |
/// println!("{}", tree.find_recursively(&vec!('H', 'G')).unwrap()); | |
/// println!("{}", tree.find_recursively(&vec!('H', 'C')).unwrap()); |
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
use std::io::{MemReader, MemWriter,IoResult, IoError, InvalidInput}; | |
trait StringReader { | |
fn read_le_string(&mut self) -> IoResult<String>; | |
} | |
impl StringReader for MemReader { | |
fn read_le_string(&mut self) -> IoResult<String> { | |
let str_b_len = self.read_le_u16(); | |
match str_b_len { |
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(quote)] | |
extern crate syntax; | |
extern crate rustc; | |
use std::collections::HashMap; | |
use std::hash::Hash; | |
use std::gc::{Gc, GC}; |
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
use std::ascii::{AsciiCast, AsciiStr}; | |
use std::comm::TryRecvError; | |
use std::io::net::tcp::TcpStream; | |
static NEW_LINE_CHAR: u8 = 0x0a; | |
static END_LINE_CHAR: u8 = 0x00; | |
static MAX_BUFFER_LENGHT: uint = 8192; |
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
#[handler="3"] | |
pub fn handle_hello_connect(client: Client, cx: Context, msg: ClientMessage) { | |
/* ... */ | |
} | |
#[deriving(Clone)] | |
pub type Handler = fn(client: Client, cx: Context, msg: ClientMessage) -> (); |
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
pub struct HelloConnectMessage { | |
salt: String, | |
key: Vec<u8> | |
} | |
impl HelloConnectMessage { | |
pub fn salt<'a>(&self) -> &'a String { | |
&self.salt | |
} | |
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(macro_rules)] | |
macro_rules! grammar( | |
($name:expr,$x:expr) => ( /* parser + generate function */) | |
) | |
grammar!("url", " | |
rule TOP { | |
<protocol>'://'<address> | |
} |
OlderNewer