Skip to content

Instantly share code, notes, and snippets.

@rmartinho
Created September 24, 2014 15:29
Show Gist options
  • Save rmartinho/bb686abaf5906ab7e9fe to your computer and use it in GitHub Desktop.
Save rmartinho/bb686abaf5906ab7e9fe to your computer and use it in GitHub Desktop.
$ cat src/main.rs
#![feature(macro_rules)]
macro_rules! doe(
($h:expr) => ($h);
($h:expr; $($t:expr);+) => (bind($h, |_| { doe!($($t);*) }));
($v:ident <- $h:expr; $($t:expr);+) => (bind($h, |$v| { doe!($($t);+) }));
)
fn main() {
doe!(
x <- foo;
return(x + 2)
);
}
$ rustc --pretty=expanded src/main.rs
#![feature(macro_rules)]
#![feature(phase)]
#![no_std]
#![feature(globs)]
#[phase(plugin, link)]
extern crate "std" as std;
extern crate "native" as rt;
#[prelude_import]
use std::prelude::*;
fn main() { bind(foo, |x| { return (x + 2) }); }
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment