Skip to content

Commit 98ec79c

Browse files
committedAug 7, 2013
auto merge of #8294 : erickt/rust/map-move, r=bblum
According to #7887, we've decided to use the syntax of `fn map<U>(f: &fn(&T) -> U) -> U`, which passes a reference to the closure, and to `fn map_move<U>(f: &fn(T) -> U) -> U` which moves the value into the closure. This PR adds these `.map_move()` functions to `Option` and `Result`. In addition, it has these other minor features: * Replaces a couple uses of `option.get()`, `result.get()`, and `result.get_err()` with `option.unwrap()`, `result.unwrap()`, and `result.unwrap_err()`. (See #8268 and #8288 for a more thorough adaptation of this functionality. * Removes `option.take_map()` and `option.take_map_default()`. These two functions can be easily written as `.take().map_move(...)`. * Adds a better error message to `result.unwrap()` and `result.unwrap_err()`.
2 parents cdba212 + 19e17f5 commit 98ec79c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+243
-211
lines changed
 

‎src/compiletest/compiletest.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ pub fn parse_config(args: ~[~str]) -> config {
109109
compile_lib_path: getopts::opt_str(matches, "compile-lib-path"),
110110
run_lib_path: getopts::opt_str(matches, "run-lib-path"),
111111
rustc_path: opt_path(matches, "rustc-path"),
112-
clang_path: getopts::opt_maybe_str(matches, "clang-path").map(|s| Path(*s)),
113-
llvm_bin_path: getopts::opt_maybe_str(matches, "llvm-bin-path").map(|s| Path(*s)),
112+
clang_path: getopts::opt_maybe_str(matches, "clang-path").map_move(|s| Path(s)),
113+
llvm_bin_path: getopts::opt_maybe_str(matches, "llvm-bin-path").map_move(|s| Path(s)),
114114
src_base: opt_path(matches, "src-base"),
115115
build_base: opt_path(matches, "build-base"),
116116
aux_base: opt_path(matches, "aux-base"),
@@ -123,14 +123,14 @@ pub fn parse_config(args: ~[~str]) -> config {
123123
} else {
124124
None
125125
},
126-
logfile: getopts::opt_maybe_str(matches, "logfile").map(|s| Path(*s)),
127-
save_metrics: getopts::opt_maybe_str(matches, "save-metrics").map(|s| Path(*s)),
126+
logfile: getopts::opt_maybe_str(matches, "logfile").map_move(|s| Path(s)),
127+
save_metrics: getopts::opt_maybe_str(matches, "save-metrics").map_move(|s| Path(s)),
128128
ratchet_metrics:
129-
getopts::opt_maybe_str(matches, "ratchet-metrics").map(|s| Path(*s)),
129+
getopts::opt_maybe_str(matches, "ratchet-metrics").map_move(|s| Path(s)),
130130
ratchet_noise_percent:
131131
getopts::opt_maybe_str(matches,
132-
"ratchet-noise-percent").map(|s|
133-
f64::from_str(*s).unwrap()),
132+
"ratchet-noise-percent").map_move(|s|
133+
f64::from_str(s).unwrap()),
134134
runtool: getopts::opt_maybe_str(matches, "runtool"),
135135
rustcflags: getopts::opt_maybe_str(matches, "rustcflags"),
136136
jit: getopts::opt_present(matches, "jit"),

‎src/compiletest/runtest.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
162162
round += 1;
163163
}
164164

165-
let mut expected =
166-
match props.pp_exact {
167-
Some(ref file) => {
165+
let mut expected = match props.pp_exact {
166+
Some(ref file) => {
168167
let filepath = testfile.dir_path().push_rel(file);
169168
io::read_whole_file_str(&filepath).unwrap()
170169
}

0 commit comments

Comments
 (0)