Skip to content

Instantly share code, notes, and snippets.

@Dretch
Dretch / gist:5273434
Created Mar 29, 2013
without the <'self> then rustc complains that 'self must be declared
View gist:5273434
trait MyTrait {
fn foo(&self);
}
impl <'self> MyTrait for &'self str {
fn foo(&self) {}
}
fn main() {}
@Dretch
Dretch / 1. The rust code
Last active Dec 15, 2015
Rustc does not like this code.
View 1. The rust 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());
View gist:4747041
enum TileType {
WALL,
FLOOR
}
pub struct Tile {
known : bool,
t : TileType
}