Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeff Belgum JeffBelgum

View GitHub Profile
@JeffBelgum
JeffBelgum / list_push_fn
Last active Dec 25, 2015
Linked List push function
View list_push_fn
#[deriving(ToStr, Clone, Eq)]
enum List<T> {
Cons(T, @mut List<T>),
Nil
}
/*
* from brson: it could be more efficient by avoiding that clone,
* since the cost of cloning a T could be arbitrary.
*
View gist:7034013
#[deriving(Clone, Eq)]
struct Node<T> {
v: T,
next: @mut Option<Node<T>>
}
#[deriving(Clone, Eq)]
struct List<T> {
priv head: @mut Option<Node<T>>
}
@JeffBelgum
JeffBelgum / list_comprehensions.rs
Created Sep 26, 2014
Python list comprehensions in Rust
View list_comprehensions.rs
#![feature(macro_rules)]
/// MIT license etc. etc.
///
/// Experimenting with Python-like list comprehensions.
///
/// An attempt to explore the possibility space for ergonomic improvements
/// in Rust that can come post v1.0. Notice that there are not type declerations.
/// Aside from the "c!" macro invocation, Rust allows for an exact copy of the
/// Python comprehension syntax.
You can’t perform that action at this time.