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 VecUtil<Elem> { | |
pub fn grouped<'r>(&'r self, n: uint) -> ~[&'r [Elem]]; | |
} | |
impl<'self, Elem> VecUtil<Elem> for &'self [Elem] { | |
fn grouped<'r>(&'r self, n: uint) -> ~[&'r [Elem]] { | |
if self.is_empty() { return ~[]; } | |
let mut res = vec::with_capacity((self.len()-1) / n + 1); |
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 args = os::args(); | |
match args.tail() { | |
[~"-n",..strs] => print(str::connect(strs, " ")), | |
strs => println(str::connect(strs, " ")), | |
} | |
} |
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 mod other; | |
fn main() { | |
other::hello(); | |
} |
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
trait Nat { } | |
struct Zero; | |
struct Suc<N>(N); | |
impl Nat for Zero { } | |
impl<N: Nat> Nat for Suc<N> { } | |
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 mut f = None; | |
match *e { | |
expr_call(f, ref args, _) => match f.node { | |
expr_path(path) => match dm.find(&f.id) { | |
Some(&v) => match v { | |
ast::def_variant(*) |ast::def_struct(*) => { | |
f = Some(expr_struct( | |
fld.fold_path(&path), | |
args.map(|x| fold_unnamed_field(*x)), | |
None |
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 t2::t3::fun; | |
mod t2; | |
fn main() { | |
t2::fun(); | |
fun(); // calling t3::fun | |
} |
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::rt::io; | |
struct HttpResponse<'self> { | |
out: &'self mut io::Writer, | |
} | |
fn write_http_header(_: &mut &mut io::Writer) {} | |
// fn write_http_header<W: io::Writer>(_: &mut W) {} | |
impl<'self> HttpResponse<'self> { |
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
trait A {} | |
fn foo<T: A>(_: &T) {} | |
struct B; | |
impl A for B {} | |
impl<'self> A for &'self A {} | |
fn main() { | |
let a = 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
fn ifV<'a, T>(rc : &str, star: &'a T) -> Option<&'a T> { | |
if (Path::new( rc )).exists() { | |
Some(star) | |
} else { | |
None | |
} | |
} |
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! report_diag ( | |
($f: tt, $name: tt, $msg: tt, $(arg: tt)*) => { { | |
reg_diag_msg!($name, $msg); | |
let msg = format!($msg, $($arg)*); | |
let msg = format!("{}: {}", stringify!($name), msg); | |
$f(msg); | |
} }; | |
($f: tt, $name: tt, $msg: tt) => { { | |
reg_diag_msg!($name, $msg); | |
let msg = format!("{}: {}", stringify!($name), $msg); |
OlderNewer