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 pop<T, ..Stack>((_, ..stack): (T, ..Stack)) -> Stack { | |
stack | |
} | |
fn dup<T: Clone, ..Stack>((x, ..stack): (T, ..Stack)) -> (T, T, ..Stack) { | |
(x.clone(), x, ..stack) | |
} | |
fn swap<T, U, ..Stack>((x, y, ..stack): (T, U, ..Stack)) -> (U, T, ..Stack) { | |
(y, x, ..stack) |
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
/* | |
Tests the Any trait. | |
*/ | |
pub struct Player { | |
name: ~str | |
} |
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 unsafe fn allocMegaGroup(mblocks: nat) -> ~Block { | |
let n = MBLOCK_GROUP_BLOCKS(mblocks); | |
enum SearchResult<'a> { | |
PerfectMatch(~Block), | |
BestMatch(&'a mut BlockData, &'a mut BlockMeta), | |
NoMatch | |
} | |
fn go<'a>(n: uint, | |
prev_link: &'a mut Option<~Block>, | |
best: Option<(&'a mut BlockData, &'a mut BlockMeta)>) |
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
// array per definizione nomi da 0 a 19 | |
static a19: [&'static str, ..20] = [ | |
"", "uno", "due", "tre", | |
"quattro","cinque", "sei", "sette", "otto", | |
"nove", "dieci", "undici", "dodici", | |
"tredici", "quattordici", "quindici", | |
"sedici", "diciassette", "diciotto", | |
"diciannove" | |
]; |
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
( | |
|a: |b: |||| a(|| {}) | |
)( | |
|b: ||| b() | |
) |
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
let (ref cfg, ref appCfg) = { | |
let prefix = Path::new(getenv("HOME").unwrap_or(~"")); | |
(prefix.join(".Sync.conf"), prefix.join(".Mirana.conf")) | |
}; |
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
let (ref cfg, ref appCfg) = if nix { | |
( Path::new ( "~/.Sync.conf" ) , | |
Path::new ( "~/.Mirana.conf" ) | |
) | |
} else { | |
let prefix = getenv("HOME").unwrap_or(~""); | |
( Path::new ( prefix + "~/.Sync.conf" ), | |
Path::new ( prefix + "~/.Mirana.conf" ) | |
) | |
}; |
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::str::*; | |
use std::hashmap::*; | |
trait CloneParser<T> { | |
fn clone_as_parser(&self) -> ~Parser<T>; | |
} | |
impl<T, U: Clone> CloneParser<T> for U { | |
fn clone_as(&self) -> ~Parser<T> { | |
~self.clone() as ~Parser<T> |
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
struct Foo(uint); | |
fn main() { | |
enum Bar { Baz(Foo) }; | |
let x = Baz(Foo(4)); | |
fn foo(_bar: uint) -> Foo { Foo(3) } | |
match x { | |
Baz(foo(x)) => println!("{:?}", x) | |
}; |
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
// | |
// btree.rs | |
// Nif Ward | |
// 10/24/13 | |
// | |
// starting implementation of a btree for rust | |
// inspired by github user davidhalperin's gist | |
//What's in a BTree? |