Skip to content

Instantly share code, notes, and snippets.

View stevenblenkinsop's full-sized avatar

Steven Blenkinsop stevenblenkinsop

View GitHub Profile
func Id(x T) T {
return x
}
@stevenblenkinsop
stevenblenkinsop / gist:7165828
Created October 26, 2013 06:05
Demonstration of ref patterns for avoiding moving out of &
enum List<T> {
End,
Node { val: T, next: ~List<T> },
}
fn print_list<T:ToStr>(list: List<T>) {
match list {
End => { println("<X>"); },
Node{val, next} => {
println(val.to_str());