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::collections::hash_map::HashMap; | |
use std::cell::Cell; | |
#[deriving(Show)] | |
struct Adder<'a>(&'a Cell<uint>); | |
impl <'a> Adder<'a> { | |
fn add(&mut self, i: uint) { | |
let &Adder(cell) = self; | |
cell.set(cell.get() + i); |
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
#![allow(dead_code)] | |
macro_rules! pipe { | |
((); $e:expr; $($args:tt)*) => ($e); | |
(($m:ident | $($ms:ident)|+) ; $($args:tt)*) => ($m!(($($ms)|+) ; $($args)*)); | |
(($m:ident) ; $($args:tt)*) => ($m!((); $($args)*)); | |
($($ms:ident)|*) => (pipe!(($($ms)|*);)); | |
} | |
macro_rules! incr { |
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
#![allow(dead_code)] | |
macro_rules! pipe { | |
((); $e:expr; $($args:tt)*) => ($e); | |
(($m:ident | $($ms:ident)|+) ; $($args:tt)*) => ($m!(($($ms)|+) ; $($args)*)); | |
(($m:ident) ; $($args:tt)*) => ($m!((); $($args)*)); | |
($($ms:ident)|*) => (pipe!(($($ms)|*);)); | |
} | |
macro_rules! zero { |
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::ops::Mul; | |
pub mod hkt { | |
pub trait HktAt<T> { | |
type Out: HasHkt<Hkt=Self, Arg=T>; | |
} | |
pub trait HasHkt { | |
type Arg; | |
type Hkt: HktAt<Self::Arg, Out=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
#![feature(fnbox)] | |
use std::ops::Mul; | |
pub mod hkt { | |
pub trait HktAt<T> { | |
type Out: HasHkt<Hkt=Self, Arg=T>; | |
} | |
pub trait HasHkt { |
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 RenderData = u32; | |
struct Manager { | |
num_entities: usize, | |
render_data: Vec<Option<RenderData>> | |
} | |
pub fn main() { | |
let mut entity_manager = Manager { |
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 RenderData = u32; | |
struct Manager { | |
#[allow(dead_code)] | |
num_entities: usize, | |
render_data: Vec<Option<RenderData>> | |
} | |
pub fn main() { |
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 RenderData = u32; | |
struct Manager { | |
render_data: Vec<Option<RenderData>> | |
} | |
pub fn main() { | |
let mut entity_manager = Manager { | |
render_data: vec![None, Some(5), None, Some(2), 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 std::ops::Deref; | |
fn main() { | |
let s: &'static str = "hello"; | |
let x: &'static str = &*s; | |
let y: &'static str = s.deref(); // <-- lifetime error | |
} |
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 T<'a> { | |
type A; | |
type Iter: Iterator<Item=Self::A>; | |
fn new() -> Self; | |
fn iter(&self) -> Self::Iter; | |
fn test() where Self: Sized { | |
let a = <Self as T<'a>>::new(); | |
let _ = a.iter().map(|a| a); |
OlderNewer