Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Demode core::result
  • Loading branch information
brson committed Sep 26, 2012
1 parent 62649f0 commit d05e2ad
Show file tree
Hide file tree
Showing 23 changed files with 153 additions and 145 deletions.
10 changes: 5 additions & 5 deletions src/cargo/cargo.rs
Expand Up @@ -460,7 +460,7 @@ fn parse_source(name: ~str, j: json::Json) -> source {
fn try_parse_sources(filename: &Path, sources: map::HashMap<~str, source>) {
if !os::path_exists(filename) { return; }
let c = io::read_whole_file_str(filename);
match json::from_str(result::get(c)) {
match json::from_str(c.get()) {
Ok(json::Dict(j)) => {
for j.each |k, v| {
sources.insert(k, parse_source(k, v));
Expand Down Expand Up @@ -579,7 +579,7 @@ fn load_source_info(c: &cargo, src: source) {
let srcfile = dir.push("source.json");
if !os::path_exists(&srcfile) { return; }
let srcstr = io::read_whole_file_str(&srcfile);
match json::from_str(result::get(srcstr)) {
match json::from_str(srcstr.get()) {
Ok(json::Dict(s)) => {
let o = parse_source(src.name, json::Dict(s));

Expand All @@ -601,7 +601,7 @@ fn load_source_packages(c: &cargo, src: source) {
let pkgfile = dir.push("packages.json");
if !os::path_exists(&pkgfile) { return; }
let pkgstr = io::read_whole_file_str(&pkgfile);
match json::from_str(result::get(pkgstr)) {
match json::from_str(pkgstr.get()) {
Ok(json::List(js)) => {
for (*js).each |j| {
match *j {
Expand Down Expand Up @@ -659,7 +659,7 @@ fn build_cargo_options(argv: ~[~str]) -> options {
fn configure(opts: options) -> cargo {
let home = match get_cargo_root() {
Ok(home) => home,
Err(_err) => result::get(get_cargo_sysroot())
Err(_err) => get_cargo_sysroot().get()
};

let get_cargo_dir = match opts.mode {
Expand All @@ -668,7 +668,7 @@ fn configure(opts: options) -> cargo {
local_mode => get_cargo_root_nearest
};

let p = result::get(get_cargo_dir());
let p = get_cargo_dir().get();

let sources = map::HashMap();
try_parse_sources(&home.push("sources.json"), sources);
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/errors.rs
Expand Up @@ -9,7 +9,7 @@ type expected_error = { line: uint, kind: ~str, msg: ~str };
// Load any test directives embedded in the file
fn load_errors(testfile: &Path) -> ~[expected_error] {
let mut error_patterns = ~[];
let rdr = result::get(io::file_reader(testfile));
let rdr = io::file_reader(testfile).get();
let mut line_num = 1u;
while !rdr.eof() {
let ln = rdr.read_line();
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/header.rs
Expand Up @@ -73,7 +73,7 @@ fn is_test_ignored(config: config, testfile: &Path) -> bool {
}
fn iter_header(testfile: &Path, it: fn(~str) -> bool) -> bool {
let rdr = result::get(io::file_reader(testfile));
let rdr = io::file_reader(testfile).get();
while !rdr.eof() {
let ln = rdr.read_line();
Expand Down
8 changes: 4 additions & 4 deletions src/compiletest/runtest.rs
Expand Up @@ -109,7 +109,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
let rounds =
match props.pp_exact { option::Some(_) => 1, option::None => 2 };

let mut srcs = ~[result::get(io::read_whole_file_str(testfile))];
let mut srcs = ~[io::read_whole_file_str(testfile).get()];

let mut round = 0;
while round < rounds {
Expand All @@ -129,7 +129,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
match props.pp_exact {
option::Some(file) => {
let filepath = testfile.dir_path().push_rel(&file);
result::get(io::read_whole_file_str(&filepath))
io::read_whole_file_str(&filepath).get()
}
option::None => { srcs[vec::len(srcs) - 2u] }
};
Expand Down Expand Up @@ -561,8 +561,8 @@ fn dump_output(config: config, testfile: &Path, out: ~str, err: ~str) {
fn dump_output_file(config: config, testfile: &Path,
out: ~str, extension: ~str) {
let outfile = make_out_name(config, testfile, extension);
let writer = result::get(
io::file_writer(&outfile, ~[io::Create, io::Truncate]));
let writer =
io::file_writer(&outfile, ~[io::Create, io::Truncate]).get();
writer.write_str(out);
}

Expand Down
6 changes: 3 additions & 3 deletions src/fuzzer/fuzzer.rs
Expand Up @@ -19,7 +19,7 @@ impl test_mode : cmp::Eq {

fn write_file(filename: &Path, content: ~str) {
result::get(
io::file_writer(filename, ~[io::Create, io::Truncate]))
&io::file_writer(filename, ~[io::Create, io::Truncate]))
.write_str(content);
}

Expand Down Expand Up @@ -543,7 +543,7 @@ fn check_convergence(files: &[Path]) {
error!("pp convergence tests: %u files", vec::len(files));
for files.each |file| {
if !file_might_not_converge(file) {
let s = @result::get(io::read_whole_file_str(file));
let s = @result::get(&io::read_whole_file_str(file));
if !content_might_not_converge(*s) {
error!("pp converge: %s", file.to_str());
// Change from 7u to 2u once
Expand All @@ -563,7 +563,7 @@ fn check_variants(files: &[Path], cx: context) {
loop;
}

let s = @result::get(io::read_whole_file_str(file));
let s = @result::get(&io::read_whole_file_str(file));
if contains(*s, ~"#") {
loop; // Macros are confusing
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/comm.rs
Expand Up @@ -459,7 +459,7 @@ fn test_recv_chan_wrong_task() {
let po = Port();
let ch = Chan(po);
send(ch, ~"flower");
assert result::is_err(task::try(||
assert result::is_err(&task::try(||
recv_chan(ch)
))
}
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/io.rs
Expand Up @@ -645,7 +645,7 @@ impl<T: Writer> T : WriterUtil {

#[allow(non_implicitly_copyable_typarams)]
fn file_writer(path: &Path, flags: ~[FileFlag]) -> Result<Writer, ~str> {
result::chain(mk_file_writer(path, flags), |w| result::Ok(w))
mk_file_writer(path, flags).chain(|w| result::Ok(w))
}


Expand Down Expand Up @@ -864,10 +864,10 @@ mod tests {
{
let out: io::Writer =
result::get(
io::file_writer(tmpfile, ~[io::Create, io::Truncate]));
&io::file_writer(tmpfile, ~[io::Create, io::Truncate]));
out.write_str(frood);
}
let inp: io::Reader = result::get(io::file_reader(tmpfile));
let inp: io::Reader = result::get(&io::file_reader(tmpfile));
let frood2: ~str = inp.read_c_str();
log(debug, frood2);
assert frood == frood2;
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/private.rs
Expand Up @@ -283,7 +283,7 @@ fn test_weaken_task_fail() {
}
}
};
assert result::is_err(res);
assert result::is_err(&res);
}

/****************************************************************************
Expand Down

0 comments on commit d05e2ad

Please sign in to comment.