Skip to content

Instantly share code, notes, and snippets.

View Dretch's full-sized avatar

Gareth Smith Dretch

View GitHub Profile
enum TileType {
WALL,
FLOOR
}
pub struct Tile {
known : bool,
t : TileType
}
@Dretch
Dretch / 1. The rust code
Last active December 15, 2015 01:49
Rustc does not like this code.
struct MyStruct {}
impl MyStruct {
fn takes_mut_self(&mut self, _x:int) {}
fn takes_self(&self) -> int { 42 }
fn also_takes_mut_self(&mut self) {
self.takes_mut_self(self.takes_self());
@Dretch
Dretch / gist:5273434
Created March 29, 2013 20:31
without the <'self> then rustc complains that 'self must be declared
trait MyTrait {
fn foo(&self);
}
impl <'self> MyTrait for &'self str {
fn foo(&self) {}
}
fn main() {}