This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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>> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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. | |
* |