🏳️⚧️
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 upcall_fail (expr=0x7fffe4a8f670 "explicit failure", | |
file=0x7fffe490a320 "/home/steven/desktop/others/sources/rust/src/libsyntax/diagnostic.rs", line=99) at /home/steven/desktop/others/sources/rust/src/rt/rust_upcall.cpp:120 | |
#1 0x00007ffff79cd6db in sys::begin_unwind_::_9873ff47b9982218::_07pre () | |
from /usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.7-pre.so | |
#2 0x00007ffff79cd682 in sys::begin_unwind::anon::anon::expr_fn_14822 () | |
from /usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.7-pre.so |
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 T (&'static [int]); | |
static t : T = T (&'static [5, 4, 3]); | |
fn main () { | |
io::println (fmt! ("%?", 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
// A typical example of idiomatic Rust code ;) | |
use core::cast; | |
use core::sys; | |
#[packed] | |
pub struct Cons <H, T> { head : H, tail : T } | |
#[packed] | |
pub struct Nil; | |
macro_rules! list ( |
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 Node<'self> | |
{ | |
Valid : bool, | |
Parent : Option<&'self Node<'self>> | |
} | |
impl<'self> Node<'self> | |
{ | |
fn new() -> Node<'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
// Rust lacks closures that can only be used once so they are emulated here. | |
priv trait OneShot <T> { | |
fn run (~self) -> T; | |
} | |
priv struct AnonymousOneShot <S, T> (S, ~fn (S) -> T); | |
impl <S, T> OneShot <T> for AnonymousOneShot <S, T> { | |
fn run (~self) -> T { | |
let ~AnonymousOneShot (x, f) = self; | |
f (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
use core::num::*; | |
use std::complex::*; | |
use core::ops::*; | |
pub struct Vector { x : f32, y : f32 } | |
pub impl Vector { | |
fn from_scalar (scalar : f32) -> Vector { Vector { x : scalar, y : scalar } } | |
fn normal_to (vector : Vector) -> Vector { | |
Vector { x : -vector.y, y : vector.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
pub trait Introspectable { | |
fn size (&self) -> uint; | |
fn raw_data (&self) -> ~[u8]; | |
fn debug_info (&self) -> ~str; | |
} | |
impl <T> Introspectable for T { | |
fn size (&self) -> uint { sys::size_of:: <T> () } | |
fn raw_data (&self) -> ~[u8] { |
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
#[link ( | |
name = "assets", | |
vers = "0.0")]; | |
pub struct Sprite { | |
indices : ~[[u16, ..3]] | |
} | |
pub struct SpriteList { |
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
/// This type is only every inhabited when S is nominally equivalent to T | |
pub type Is <S, T> = Is_ <S, T>; | |
priv struct Is_ <S, T>; | |
// Construct a proof of the fact that a type is nominally equivalent | |
// to itself. | |
pub fn Is <T> () -> Is <T, T> { Is_ } | |
pub impl <S, T> Is_ <S, 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
/// A data type for making a type which is not moveable by | |
/// default. This is useful for marking large types which are | |
/// expensive to copy around. | |
pub struct NonMoveable<'self> { | |
/// Never actually used but only for guaranteeing certain | |
/// properties by default | |
priv contents: &'self() | |
} | |
pub fn NonMoveable<T>(f : &fn(NonMoveable) -> T) -> T { |
OlderNewer