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 Show { | |
#[derive_scheme( | |
TupleLike { try!(fmt.write_str(concat!($_name, "("))); try!($_); fmt.write(b")") } | |
StructLike { try!(fmt.write_str(concat!($_name, "{"))); try!($_); fmt.write(b"}") } | |
UnitLike { fmt.write_str($_name) } | |
AnonymousList { try!($_);try!(fmt.write_str(",")) } | |
NamedList { try!(fmt.write_str(concat!($_name, ":")));try!($_);try!(fmt.write_str(",")) } | |
)] | |
fn fmt(&self, fmt: &mut Formatter) -> Result; | |
} |
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
// <core> | |
#[lang="vtable"] | |
struct Vtable<T, Sized? Trait>(&'static (unsafe fn(*mut T), uint, uint)); | |
extern "rust-intrinsic" { fn get_vtable<T, Sized? Trait>() -> Vtable<T, Trait>; } | |
#[lang="has_vtable"] | |
trait HasVtable<T, Sized? Trait> {} | |
// </core> | |
#[repr(fixed, inline_vtable)] | |
trait Node: Any { |
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::num::zero; | |
use std::rand::Rng; | |
use std::rand::distributions::range::SampleRange; | |
use vecmath::vector::Vec3; | |
use vecmath::ray::Ray; | |
use lightray::Lightray; | |
use objecthit::ObjectHit; |
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 linked_face(vertexes: &[Rc<RefCell<Vertex>>], face: UnlinkedFace) -> Option<RefCell<Face>> { | |
Some(RefCell::new(Face { | |
a: match vertexes.get(face.a) { | |
Some(x) => x.clone(), | |
None => return None | |
}, | |
b: match vertexes.get(face.b) { | |
Some(x) => x.clone(), | |
None => return 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
static NTASKS: uint = 10; | |
fn main() { | |
let mut array = [0u, ..NTASKS]; | |
for (x, i) in array.mut_iter().enumerate() { | |
let ptr = x as *mut _; | |
spawn(proc() { | |
let inner_x = unsafe {&mut *ptr}; |
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
0: Split(1, 5) | |
1: OneChar(a, 0) | |
2: CharClass([(b, c)], 0) | |
3: OneChar(d, 0) | |
4: Match | |
5: OneChar(r, 0) | |
6: Split(5, 7) | |
7: Match |
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 Blob<HEADER> { | |
data:~[u8], | |
} | |
impl<T> std::ops::Deref<T> for Blob<T> { | |
fn deref<'s>(&'s self)->&'s T { | |
//assert!(self.num_bytes() > std::intrinsics::size_of::<T>()); | |
unsafe { &*(&self.data[0] as *u8 as *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
mod config { | |
pub enum Node<T> { | |
Directory(~str, ~[Node<T>]), | |
Entry(~str, T) | |
} | |
impl<T> Node<T> { | |
pub fn add(&mut self, entry: Node<T>) -> Option<&mut self> { | |
let succeeded = match *self { | |
Directory(_, ref mut list) => { list.push(entry); true } |
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
mod config { | |
pub enum Node<T> { | |
Directory(~str, ~[Node<T>]), | |
Entry(~str, T) | |
} | |
impl<T> Node<T> { | |
pub fn add(&mut self, entry: Node<T>) -> bool { | |
match *self { | |
Directory(_, ref mut list) => { list.push(entry); true } |
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
type ParseResult<S, R> = Result<(R, ~[S]), ~str>; | |
enum Parser<'a, S, R> { | |
Parser('a |&[S]| -> ~[ParseResult<S, R>]) | |
} | |
fn main() { | |
let p = Parser(/* missing argument here */); | |
println!("test"); | |
} |