Skip to content

Instantly share code, notes, and snippets.

@benw
benw / list.rs
Created May 28, 2013 02:12
In which I learn to use the ref keyword.
enum List {
Nil,
Node(int, ~List)
}
fn walk(l: &List) -> ~str {
match *l {
Node(i, ref rest) => fmt!("%d %s", i, walk(*rest)),
Nil => ~"end"
}
trait Fruit {
fn eat(&self);
}
struct Apple {
x: int
}
impl Fruit for Apple {
fn eat(&self) {
@benw
benw / create_tables.sql
Created February 7, 2016 20:17
Postgres schema for reasonwell.com
\set ON_ERROR_STOP
CREATE TABLE Sites (
id SERIAL PRIMARY KEY,
base_url VARCHAR NOT NULL,
title VARCHAR NOT NULL,
public_read BOOLEAN NOT NULL DEFAULT FALSE,
allow_anyone BOOLEAN NOT NULL DEFAULT FALSE,
allow_unverified BOOLEAN NOT NULL DEFAULT FALSE,