Skip to content

Instantly share code, notes, and snippets.

@ben0x539
Created July 9, 2012 21:25
Show Gist options
  • Save ben0x539/3079049 to your computer and use it in GitHub Desktop.
Save ben0x539/3079049 to your computer and use it in GitHub Desktop.
use std;
import result::{result, ok, chain};
fn read_file(filename: str) -> result<@str, @str> {
ret ok(@("<contents of " + filename + ">"));
}
fn parse_buf(buf: @str) -> @str {
ret @("<parsed: " + *buf + ">");
}
fn main(_args: ~[str]) {
let res = do chain(read_file("foo")) |buf| {
ok(parse_buf(buf))
};
log(info, res);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment