Skip to content

Commit 4a78f9b

Browse files
committed
core: Demode option
1 parent 92752a4 commit 4a78f9b

Some content is hidden

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

81 files changed

+325
-313
lines changed

src/cargo/cargo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ fn install_one_crate(c: &cargo, path: &Path, cf: &Path) {
805805
if (exec_suffix != ~"" && str::ends_with(ct.to_str(),
806806
exec_suffix)) ||
807807
(exec_suffix == ~"" &&
808-
!str::starts_with(option::get(ct.filename()),
808+
!str::starts_with(ct.filename().get(),
809809
~"lib")) {
810810
debug!(" bin: %s", ct.to_str());
811811
install_to_dir(*ct, &c.bindir);
@@ -874,8 +874,8 @@ fn install_source(c: &cargo, path: &Path) {
874874

875875
fn install_git(c: &cargo, wd: &Path, url: ~str, reference: Option<~str>) {
876876
run::program_output(~"git", ~[~"clone", url, wd.to_str()]);
877-
if option::is_some(reference) {
878-
let r = option::get(reference);
877+
if reference.is_some() {
878+
let r = reference.get();
879879
os::change_dir(wd);
880880
run::run_program(~"git", ~[~"checkout", r]);
881881
}
@@ -1597,7 +1597,7 @@ fn cmd_search(c: &cargo) {
15971597
}
15981598

15991599
fn install_to_dir(srcfile: &Path, destdir: &Path) {
1600-
let newfile = destdir.push(option::get(srcfile.filename()));
1600+
let newfile = destdir.push(srcfile.filename().get());
16011601

16021602
let status = run::run_program(~"cp", ~[~"-r", srcfile.to_str(),
16031603
newfile.to_str()]);

src/compiletest/compiletest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn parse_config(args: ~[~str]) -> config {
5656
if vec::len(matches.free) > 0u {
5757
option::Some(matches.free[0])
5858
} else { option::None },
59-
logfile: option::map(getopts::opt_maybe_str(matches,
59+
logfile: option::map(&getopts::opt_maybe_str(matches,
6060
~"logfile"),
6161
|s| Path(s)),
6262
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
@@ -155,7 +155,7 @@ fn is_test(config: config, testfile: &Path) -> bool {
155155
_ => ~[~".rc", ~".rs"]
156156
};
157157
let invalid_prefixes = ~[~".", ~"#", ~"~"];
158-
let name = option::get(testfile.filename());
158+
let name = testfile.filename().get();
159159

160160
let mut valid = false;
161161

src/compiletest/header.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ fn load_props(testfile: &Path) -> test_props {
3232
option::None => ()
3333
};
3434

35-
if option::is_none(compile_flags) {
35+
if compile_flags.is_none() {
3636
compile_flags = parse_compile_flags(ln);
3737
}
3838

39-
if option::is_none(pp_exact) {
39+
if pp_exact.is_none() {
4040
pp_exact = parse_pp_exact(ln, testfile);
4141
}
4242

43-
do option::iter(parse_aux_build(ln)) |ab| {
43+
do parse_aux_build(ln).iter |ab| {
4444
vec::push(aux_builds, ab);
4545
}
4646

47-
do option::iter(parse_exec_env(ln)) |ee| {
47+
do parse_exec_env(ln).iter |ee| {
4848
vec::push(exec_env, ee);
4949
}
5050
};

src/compiletest/procsrv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ fn run(lib_path: ~str,
8989
}
9090

9191
fn writeclose(fd: c_int, s: Option<~str>) {
92-
if option::is_some(s) {
92+
if s.is_some() {
9393
let writer = io::fd_writer(fd, false);
94-
writer.write_str(option::get(s));
94+
writer.write_str(s.get());
9595
}
9696

9797
os::close(fd);

src/compiletest/runtest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn run_rpass_test(config: config, props: test_props, testfile: &Path) {
102102
}
103103
104104
fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
105-
if option::is_some(props.pp_exact) {
105+
if props.pp_exact.is_some() {
106106
logv(config, ~"testing for exact pretty-printing");
107107
} else { logv(config, ~"testing for converging pretty-printing"); }
108108

@@ -135,7 +135,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
135135
};
136136
let mut actual = srcs[vec::len(srcs) - 1u];
137137

138-
if option::is_some(props.pp_exact) {
138+
if props.pp_exact.is_some() {
139139
// Now we have to care about line endings
140140
let cr = ~"\r";
141141
actual = str::replace(actual, cr, ~"");
@@ -575,7 +575,7 @@ fn aux_output_dir_name(config: config, testfile: &Path) -> Path {
575575
}
576576
577577
fn output_testname(testfile: &Path) -> Path {
578-
Path(option::get(testfile.filestem()))
578+
Path(testfile.filestem().get())
579579
}
580580
581581
fn output_base_name(config: config, testfile: &Path) -> Path {

src/fuzzer/fuzzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ fn check_variants_T<T: Copy>(
305305
}
306306

307307
fn last_part(filename: ~str) -> ~str {
308-
let ix = option::get(str::rfind_char(filename, '/'));
308+
let ix = option::get(&str::rfind_char(filename, '/'));
309309
str::slice(filename, ix + 1u, str::len(filename) - 3u)
310310
}
311311

src/libcore/dlist.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl<T> DList<T> {
211211
fn push_head_n(+data: T) -> DListNode<T> {
212212
let mut nobe = self.new_link(move data);
213213
self.add_head(nobe);
214-
option::get(nobe)
214+
option::get(&nobe)
215215
}
216216
/// Add data to the tail of the list. O(1).
217217
fn push(+data: T) {
@@ -224,7 +224,7 @@ impl<T> DList<T> {
224224
fn push_n(+data: T) -> DListNode<T> {
225225
let mut nobe = self.new_link(move data);
226226
self.add_tail(nobe);
227-
option::get(nobe)
227+
option::get(&nobe)
228228
}
229229
/**
230230
* Insert data into the middle of the list, left of the given node.
@@ -248,7 +248,7 @@ impl<T> DList<T> {
248248
fn insert_before_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
249249
let mut nobe = self.new_link(move data);
250250
self.insert_left(nobe, neighbour);
251-
option::get(nobe)
251+
option::get(&nobe)
252252
}
253253
/**
254254
* Insert data into the middle of the list, right of the given node.
@@ -272,7 +272,7 @@ impl<T> DList<T> {
272272
fn insert_after_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
273273
let mut nobe = self.new_link(move data);
274274
self.insert_right(neighbour, nobe);
275-
option::get(nobe)
275+
option::get(&nobe)
276276
}
277277
278278
/// Remove a node from the head of the list. O(1).
@@ -380,21 +380,25 @@ impl<T> DList<T> {
380380

381381
/// Check data structure integrity. O(n).
382382
fn assert_consistent() {
383-
if option::is_none(self.hd) || option::is_none(self.tl) {
384-
assert option::is_none(self.hd) && option::is_none(self.tl);
383+
if option::is_none(&self.hd) || option::is_none(&self.tl) {
384+
assert option::is_none(&self.hd) && option::is_none(&self.tl);
385385
}
386386
// iterate forwards
387387
let mut count = 0;
388388
let mut link = self.peek_n();
389389
let mut rabbit = link;
390-
while option::is_some(link) {
391-
let nobe = option::get(link);
390+
while option::is_some(&link) {
391+
let nobe = option::get(&link);
392392
assert nobe.linked;
393393
// check cycle
394-
if option::is_some(rabbit) { rabbit = option::get(rabbit).next; }
395-
if option::is_some(rabbit) { rabbit = option::get(rabbit).next; }
396-
if option::is_some(rabbit) {
397-
assert !box::ptr_eq(*option::get(rabbit), *nobe);
394+
if option::is_some(&rabbit) {
395+
rabbit = option::get(&rabbit).next;
396+
}
397+
if option::is_some(&rabbit) {
398+
rabbit = option::get(&rabbit).next;
399+
}
400+
if option::is_some(&rabbit) {
401+
assert !box::ptr_eq(*option::get(&rabbit), *nobe);
398402
}
399403
// advance
400404
link = nobe.next_link();
@@ -404,14 +408,18 @@ impl<T> DList<T> {
404408
// iterate backwards - some of this is probably redundant.
405409
link = self.peek_tail_n();
406410
rabbit = link;
407-
while option::is_some(link) {
408-
let nobe = option::get(link);
411+
while option::is_some(&link) {
412+
let nobe = option::get(&link);
409413
assert nobe.linked;
410414
// check cycle
411-
if option::is_some(rabbit) { rabbit = option::get(rabbit).prev; }
412-
if option::is_some(rabbit) { rabbit = option::get(rabbit).prev; }
413-
if option::is_some(rabbit) {
414-
assert !box::ptr_eq(*option::get(rabbit), *nobe);
415+
if option::is_some(&rabbit) {
416+
rabbit = option::get(&rabbit).prev;
417+
}
418+
if option::is_some(&rabbit) {
419+
rabbit = option::get(&rabbit).prev;
420+
}
421+
if option::is_some(&rabbit) {
422+
assert !box::ptr_eq(*option::get(&rabbit), *nobe);
415423
}
416424
// advance
417425
link = nobe.prev_link();

src/libcore/gc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ fn cleanup_stack_for_failure() {
328328
let mut roots = ~RootSet();
329329
for walk_gc_roots(need_cleanup, sentinel) |root, tydesc| {
330330
// Track roots to avoid double frees.
331-
if option::is_some(roots.find(&*root)) {
331+
if roots.find(&*root).is_some() {
332332
loop;
333333
}
334334
roots.insert(*root, ());

src/libcore/iter-trait/dlist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ type IMPL_T<A> = dlist::DList<A>;
1010
*/
1111
pure fn EACH<A>(self: IMPL_T<A>, f: fn(v: &A) -> bool) {
1212
let mut link = self.peek_n();
13-
while option::is_some(link) {
14-
let nobe = option::get(link);
13+
while option::is_some(&link) {
14+
let nobe = option::get(&link);
1515
assert nobe.linked;
1616
if !f(&nobe.data) { break; }
1717
// Check (weakly) that the user didn't do a remove.

0 commit comments

Comments
 (0)