Skip to content

Commit 1e49081

Browse files
committed
core: option.map_consume -> option.map_move
1 parent 9218aaa commit 1e49081

Some content is hidden

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

53 files changed

+176
-175
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/libextra/dlist.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl<T> DList<T> {
164164
/// Remove the first Node and return it, or None if the list is empty
165165
#[inline]
166166
fn pop_front_node(&mut self) -> Option<~Node<T>> {
167-
do self.list_head.take().map_consume |mut front_node| {
167+
do self.list_head.take().map_move |mut front_node| {
168168
self.length -= 1;
169169
match front_node.next.take() {
170170
Some(node) => self.list_head = link_with_prev(node, Rawlink::none()),
@@ -190,7 +190,7 @@ impl<T> DList<T> {
190190
/// Remove the last Node and return it, or None if the list is empty
191191
#[inline]
192192
fn pop_back_node(&mut self) -> Option<~Node<T>> {
193-
do self.list_tail.resolve().map_consume_default(None) |tail| {
193+
do self.list_tail.resolve().map_move_default(None) |tail| {
194194
self.length -= 1;
195195
self.list_tail = tail.prev;
196196
match tail.prev.resolve() {
@@ -237,7 +237,7 @@ impl<T> Deque<T> for DList<T> {
237237
///
238238
/// O(1)
239239
fn pop_front(&mut self) -> Option<T> {
240-
self.pop_front_node().map_consume(|~Node{value, _}| value)
240+
self.pop_front_node().map_move(|~Node{value, _}| value)
241241
}
242242

243243
/// Add an element last in the list
@@ -251,7 +251,7 @@ impl<T> Deque<T> for DList<T> {
251251
///
252252
/// O(1)
253253
fn pop_back(&mut self) -> Option<T> {
254-
self.pop_back_node().map_consume(|~Node{value, _}| value)
254+
self.pop_back_node().map_move(|~Node{value, _}| value)
255255
}
256256
}
257257

@@ -267,7 +267,7 @@ impl<T> DList<T> {
267267
/// If the list is empty, do nothing.
268268
#[inline]
269269
pub fn rotate_forward(&mut self) {
270-
do self.pop_back_node().map_consume |tail| {
270+
do self.pop_back_node().map_move |tail| {
271271
self.push_front_node(tail)
272272
};
273273
}
@@ -277,7 +277,7 @@ impl<T> DList<T> {
277277
/// If the list is empty, do nothing.
278278
#[inline]
279279
pub fn rotate_backward(&mut self) {
280-
do self.pop_front_node().map_consume |head| {
280+
do self.pop_front_node().map_move |head| {
281281
self.push_back_node(head)
282282
};
283283
}
@@ -463,7 +463,7 @@ impl<'self, A> DoubleEndedIterator<&'self A> for DListIterator<'self, A> {
463463
if self.nelem == 0 {
464464
return None;
465465
}
466-
do self.tail.resolve().map_consume |prev| {
466+
do self.tail.resolve().map_move |prev| {
467467
self.nelem -= 1;
468468
self.tail = prev.prev;
469469
&prev.value
@@ -477,7 +477,7 @@ impl<'self, A> Iterator<&'self mut A> for MutDListIterator<'self, A> {
477477
if self.nelem == 0 {
478478
return None;
479479
}
480-
do self.head.resolve().map_consume |next| {
480+
do self.head.resolve().map_move |next| {
481481
self.nelem -= 1;
482482
self.head = match next.next {
483483
Some(ref mut node) => Rawlink::some(&mut **node),
@@ -499,7 +499,7 @@ impl<'self, A> DoubleEndedIterator<&'self mut A> for MutDListIterator<'self, A>
499499
if self.nelem == 0 {
500500
return None;
501501
}
502-
do self.tail.resolve().map_consume |prev| {
502+
do self.tail.resolve().map_move |prev| {
503503
self.nelem -= 1;
504504
self.tail = prev.prev;
505505
&mut prev.value
@@ -553,7 +553,7 @@ impl<'self, A> ListInsertion<A> for MutDListIterator<'self, A> {
553553
if self.nelem == 0 {
554554
return None
555555
}
556-
self.head.resolve().map_consume(|head| &mut head.value)
556+
self.head.resolve().map_move(|head| &mut head.value)
557557
}
558558
}
559559

src/libextra/num/bigint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ impl BigUint {
548548
549549
pub fn new(v: ~[BigDigit]) -> BigUint {
550550
// omit trailing zeros
551-
let new_len = v.rposition(|n| *n != 0).map_default(0, |p| *p + 1);
551+
let new_len = v.rposition(|n| *n != 0).map_move_default(0, |p| p + 1);
552552

553553
if new_len == v.len() { return BigUint { data: v }; }
554554
let mut v = v;
@@ -1145,7 +1145,7 @@ impl BigInt {
11451145
start = 1;
11461146
}
11471147
return BigUint::parse_bytes(buf.slice(start, buf.len()), radix)
1148-
.map_consume(|bu| BigInt::from_biguint(sign, bu));
1148+
.map_move(|bu| BigInt::from_biguint(sign, bu));
11491149
}
11501150
11511151
pub fn to_uint(&self) -> uint {

src/libextra/smallintmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl<V> SmallIntMap<V> {
203203
{
204204
let values = replace(&mut self.v, ~[]);
205205
values.consume_iter().enumerate().filter_map(|(i, v)| {
206-
v.map_consume(|v| (i, v))
206+
v.map_move(|v| (i, v))
207207
})
208208
}
209209
}

src/libextra/term.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl Terminal {
127127
let inf = ti.unwrap();
128128
let nc = if inf.strings.find_equiv(&("setaf")).is_some()
129129
&& inf.strings.find_equiv(&("setab")).is_some() {
130-
inf.numbers.find_equiv(&("colors")).map_consume_default(0, |&n| n)
130+
inf.numbers.find_equiv(&("colors")).map_move_default(0, |&n| n)
131131
} else { 0 };
132132

133133
return Ok(Terminal {out: out, ti: inf, num_colors: nc});
@@ -220,7 +220,7 @@ impl Terminal {
220220
cap = self.ti.strings.find_equiv(&("op"));
221221
}
222222
}
223-
let s = do cap.map_consume_default(Err(~"can't find terminfo capability `sgr0`")) |op| {
223+
let s = do cap.map_move_default(Err(~"can't find terminfo capability `sgr0`")) |op| {
224224
expand(*op, [], &mut Variables::new())
225225
};
226226
if s.is_ok() {

src/libextra/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,20 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
238238
let run_ignored = getopts::opt_present(&matches, "ignored");
239239

240240
let logfile = getopts::opt_maybe_str(&matches, "logfile");
241-
let logfile = logfile.map(|s| Path(*s));
241+
let logfile = logfile.map_move(|s| Path(s));
242242

243243
let run_benchmarks = getopts::opt_present(&matches, "bench");
244244
let run_tests = ! run_benchmarks ||
245245
getopts::opt_present(&matches, "test");
246246

247247
let ratchet_metrics = getopts::opt_maybe_str(&matches, "ratchet-metrics");
248-
let ratchet_metrics = ratchet_metrics.map(|s| Path(*s));
248+
let ratchet_metrics = ratchet_metrics.map_move(|s| Path(s));
249249

250250
let ratchet_noise_percent = getopts::opt_maybe_str(&matches, "ratchet-noise-percent");
251-
let ratchet_noise_percent = ratchet_noise_percent.map(|s| f64::from_str(*s).unwrap());
251+
let ratchet_noise_percent = ratchet_noise_percent.map_move(|s| f64::from_str(s).unwrap());
252252

253253
let save_metrics = getopts::opt_maybe_str(&matches, "save-metrics");
254-
let save_metrics = save_metrics.map(|s| Path(*s));
254+
let save_metrics = save_metrics.map_move(|s| Path(s));
255255

256256
let test_opts = TestOpts {
257257
filter: filter,

src/libextra/treemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ impl<'self, T> Iterator<&'self T> for TreeSetIterator<'self, T> {
394394
/// Advance the iterator to the next node (in order). If there are no more nodes, return `None`.
395395
#[inline]
396396
fn next(&mut self) -> Option<&'self T> {
397-
do self.iter.next().map |&(value, _)| { value }
397+
do self.iter.next().map_move |(value, _)| { value }
398398
}
399399
}
400400

src/librust/rust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn rustc_help() {
130130
fn find_cmd(command_string: &str) -> Option<Command> {
131131
do COMMANDS.iter().find_ |command| {
132132
command.cmd == command_string
133-
}.map_consume(|x| *x)
133+
}.map_move(|x| *x)
134134
}
135135

136136
fn cmd_help(args: &[~str]) -> ValidUsage {

src/librustc/driver/driver.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,7 @@ pub fn build_session_options(binary: @str,
669669
} else if opt_present(matches, "emit-llvm") {
670670
link::output_type_bitcode
671671
} else { link::output_type_exe };
672-
let sysroot_opt = getopts::opt_maybe_str(matches, "sysroot");
673-
let sysroot_opt = sysroot_opt.map(|m| @Path(*m));
672+
let sysroot_opt = getopts::opt_maybe_str(matches, "sysroot").map_move(|m| @Path(m));
674673
let target_opt = getopts::opt_maybe_str(matches, "target");
675674
let target_feature_opt = getopts::opt_maybe_str(matches, "target-feature");
676675
let save_temps = getopts::opt_present(matches, "save-temps");

src/librustc/front/config.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ fn fold_mod(cx: @Context, m: &ast::_mod, fld: @fold::ast_fold) -> ast::_mod {
6161
filter_item(cx, *a).chain(|x| fld.fold_item(x))
6262
}.collect();
6363
let filtered_view_items = do m.view_items.iter().filter_map |a| {
64-
filter_view_item(cx, a).map(|&x| fld.fold_view_item(x))
64+
do filter_view_item(cx, a).map_move |x| {
65+
fld.fold_view_item(x)
66+
}
6567
}.collect();
6668
ast::_mod {
6769
view_items: filtered_view_items,
@@ -83,7 +85,9 @@ fn fold_foreign_mod(
8385
) -> ast::foreign_mod {
8486
let filtered_items = nm.items.iter().filter_map(|a| filter_foreign_item(cx, *a)).collect();
8587
let filtered_view_items = do nm.view_items.iter().filter_map |a| {
86-
filter_view_item(cx, a).map(|&x| fld.fold_view_item(x))
88+
do filter_view_item(cx, a).map_move |x| {
89+
fld.fold_view_item(x)
90+
}
8791
}.collect();
8892
ast::foreign_mod {
8993
sort: nm.sort,
@@ -138,7 +142,7 @@ fn fold_block(
138142
filter_stmt(cx, *a).chain(|stmt| fld.fold_stmt(stmt))
139143
}.collect();
140144
let filtered_view_items = do b.view_items.iter().filter_map |a| {
141-
filter_view_item(cx, a).map(|&x| fld.fold_view_item(x))
145+
filter_view_item(cx, a).map(|x| fld.fold_view_item(*x))
142146
}.collect();
143147
ast::Block {
144148
view_items: filtered_view_items,

0 commit comments

Comments
 (0)