Skip to content

Instantly share code, notes, and snippets.

enum StrangeCountIterator { priv A(int), priv B(int) }
impl Iterator<int> for StrangeCountIterator {
fn next(&mut self) -> Option<int> {
match *self {
A(mut i) => {
i += 1;
*self = B(i)
return Some(i);
}
@huonw
huonw / basic.rs
Last active December 20, 2015 14:19
match 'foo {
'foo => {
if some_thing {
match 'bar;
} else if other_thing {
match 'baz;
}
}
'bar => { blah(); match 'baz; }
'baz => { blahblah(); match 'foo; }