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
fn main() { | |
let flip = |(x,y)| (y, x); | |
println(fmt!("%?", flip((-9i,0i)))); | |
} |
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
impl<K: Eq + Hash, V, T: Iterator<(K, V)>> FromIterator<(K, V), T> for HashMap<K, V> { | |
pub fn from_iterator(iter: &mut T) -> HashMap<K, V> { | |
let (lower, _) = iter.size_hint(); | |
let mut map = HashMap::with_capacity(lower); | |
for iter.advance |(k, v)| { | |
map.insert(k, v); | |
} | |
map |
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 trait Transformer<From,To, Err: ToStr> { | |
fn one_shot(&mut self, input: &[From]) -> Result<~[To],Err>; | |
fn stream(&mut self, input: &[From], blk: &fn(&[To]); | |
} | |
pub trait Codec<D,E, Err: ToStr> { | |
fn encoder(&self) -> Transformer<D,E,Err>; | |
fn decoder(&self) -> Transformer<E,D,Err>; | |
fn encode(&self, input: &[D]) -> Result<~[E],~Err>; | |
fn decode(&self, input: &[E]) -> Result<~[D],~Err>; |
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
macro_rules! Ξ ( | |
($name:expr) => ( | |
($name).to_str() | |
) | |
) | |
println( Ξ!(1 * 6 + 6 - 8 * 5 + 5 * 7i)); |
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
start: BZ_OK | |
err: BZ_RUN_OK, buff_sz: 10000, stream.avail_out: 10000, buff_sz - stream,avail_out: 0 | |
end: BZ_RUN_OK | |
start: BZ_RUN_OK | |
err: BZ_STREAM_END, buff_sz: 10000, stream.avail_out: 6887, buff_sz - stream,avail_out: 3113 | |
end: BZ_STREAM_END | |
err: BZ_STREAM_END, buff_sz: 10000, stream.avail_out: 10000, buff_sz - stream,avail_out: 0 |
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
// curl/opt.rs | |
macro_rules! CINIT( | |
($name:ident, $typ:expr, $val:expr) => ( | |
$name = $typ + $val, | |
) | |
) | |
static LONG: i32 = 0i32; |
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
// traitfail.rs | |
trait Slide { | |
fn new(x: int) -> Self; | |
fn x_mut<'r> (&'r mut self) -> &'r mut int; | |
fn x(&self) -> int; | |
} | |
struct Bead { | |
x: int |
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
// mummy.rs | |
use pc::PC; | |
use common::{Character}; | |
#[deriving(ToStr)] | |
pub struct Mummy { | |
hp: uint, | |
attack: uint, | |
x: int, |
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
// listen.rs | |
use extra::net::ip; | |
use extra::net::tcp; | |
use std::task; | |
pub fn server_loop() { | |
use extra::uv::iotask::spawn_iotask; | |
let mut builder = task::task(); |
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
#[deriving(Eq,Rand)] | |
pub enum Card { | |
One = 1, | |
Two, | |
Three, | |
Four, | |
Five, | |
Six, | |
Seven, | |
Eight, |