Skip to content

Instantly share code, notes, and snippets.

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6eM0HyzqV74EmpZU3HVyxjfKswJuJXG2gBJVSasiHiVJ/wqyZ1rXx/rpOBlOENH5V+oSk/2iwVZpiQpn9jmrgfIbQydCoLSWt0hsGgLpYmdqO2O4qJQD0RE7EUNfXGnpeRyFekQh6ud9koah2w2sMX4Wnbfx5wZdB1gUZnBIHzmMZ49SZHTHijwHcrjQF50dAc51on63ioE1qlaaKWLPCUZT7OFd7iws8KXRH/UF2wEStZnzPu4wGulIkd+g6frFrWm6fgN90qJKQwTBQZuStnENQyHDVNKmCbHSQ1oLnjo+aw8SyLtIWJLgnATlJHl3nQZfztP7r+cL5Zi7dQ2ruQ== eholk@host-5-97.mv.mozilla.com
/// Map representation
use std;
import io::reader_util;
enum square {
bot,
wall,
rock,
@eholk
eholk / gist:3124550
Created July 16, 2012 19:33
Various terminal state examples
// Current
proto! oneshot {
waiting:send {
signal -> signaled
}
signaled:send { }
}
rust: ~"reflect::visit_ty str/3"
rust: ~"type_of 4381794416: @(ty_estr(vstore_fixed(3)), 302, 0, none)"
rust: ~"passing 3 args:"
rust: ~"arg 0: i64"
rust: ~"arg 1: i64"
rust: ~"arg 2: i64"
rust: ~"new insn_ctxt: with_scope"
rust: ~"new insn_ctxt: impl::trans_trait_callee"
rust: ~"type_of 4381300832: @(ty_bool, 10, 0, none)"
rust: ~"type_of 4381417504: @(ty_uint(0), 7, 0, none)"
trait bar<T> {
fn get_bar() -> T;
}
fn foo<T, U: bar<T>>(b: U) -> T {
b.get_bar()
}
class cbar : bar<int> {
let x: int;
fn test() {
macro_rules! lambda {
{ $x:ident => $e:expr } => {|$x| $e}
}
fn foo(_f: fn(int) -> int) { fail }
foo(lambda!{x => x});
}
// xfail-pretty
// An example of the bank protocol from eholk's blog post.
//
// http://theincredibleholk.wordpress.com/2012/07/06/rusty-pipes/
import pipes::try_recv;
type username = ~str;
type password = ~str;
@eholk
eholk / Pipe Syntax Extensions.md
Created July 18, 2012 23:40
Pipe syntax extensions

Here are some ideas to make working with pipes easier.

This one combines the receive and the match with some sugar to handle moving the next state out of the message enum. This also hides the implementation of the message format from the programmer.

fn client_follow(+bank: bank::client::login) {
    import bank::*;

    let bank = client::login(bank, ~"theincredibleholk", ~"1234");
    let bank = switch(bank, follow! {
// Transitional reexports so qquote can find the paths it is looking for
mod syntax {
import ext;
export ext;
import parse;
export parse;
}
Program received signal EXC_SOFTWARE, Software generated exception.
0x00007fff8fda7bca in __psynch_cvwait ()
(gdb) bt
#0 0x00007fff8fda7bca in __psynch_cvwait ()
#1 0x00007fff9628b274 in _pthread_cond_wait ()
#2 0x00000001007d6b6f in lock_and_signal::wait (this=0x101015cf8) at lock_and_signal.cpp:105
#3 0x00000001007dd23b in rust_sched_driver::start_main_loop (this=0x101015cf8) at rust_sched_driver.cpp:34
#4 0x00000001007e4fa8 in rust_kernel::run (this=0x101015cf8) at rust_kernel.cpp:186
#5 0x00000001007d71ec in rust_start (main_fn=1341408481166592, argc=22, argv=0x7fff5fbff770, crate_map=0x101015cf8) at rust.cpp:120
#6 0x0000000100001124 in start ()