Skip to content

Commit 34c5a09

Browse files
committed
option: rm functions that duplicate methods
1 parent 5011d05 commit 34c5a09

Some content is hidden

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

48 files changed

+210
-383
lines changed

src/compiletest/compiletest.rc

+1-3
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ pub fn parse_config(args: ~[~str]) -> config {
9090
if vec::len(matches.free) > 0u {
9191
option::Some(matches.free[0])
9292
} else { option::None },
93-
logfile: option::map(&getopts::opt_maybe_str(matches,
94-
~"logfile"),
95-
|s| Path(*s)),
93+
logfile: getopts::opt_maybe_str(matches, ~"logfile").map(|s| Path(*s)),
9694
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
9795
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
9896
jit: getopts::opt_present(matches, ~"jit"),

src/libcore/cell.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! A mutable, nullable memory location
1212
1313
use cast::transmute;
14-
use option;
1514
use prelude::*;
1615

1716
/*
@@ -53,7 +52,7 @@ pub impl<T> Cell<T> {
5352
5453
let mut value = None;
5554
value <-> self.value;
56-
return option::unwrap(value);
55+
value.unwrap()
5756
}
5857
5958
/// Returns the value, failing if the cell is full.

src/libcore/comm.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ Message passing
1515
use cast;
1616
use either::{Either, Left, Right};
1717
use kinds::Owned;
18-
use option;
19-
use option::{Option, Some, None, unwrap};
18+
use option::{Option, Some, None};
2019
use uint;
2120
use unstable;
2221
use vec;
@@ -126,7 +125,7 @@ fn chan_send<T:Owned>(self: &Chan<T>, x: T) {
126125
let mut endp = None;
127126
endp <-> self.endp;
128127
self.endp = Some(
129-
streamp::client::data(unwrap(endp), x))
128+
streamp::client::data(endp.unwrap(), x))
130129
}
131130
132131
impl<T: Owned> GenericSmartChan<T> for Chan<T> {
@@ -139,7 +138,7 @@ impl<T: Owned> GenericSmartChan<T> for Chan<T> {
139138
fn chan_try_send<T:Owned>(self: &Chan<T>, x: T) -> bool {
140139
let mut endp = None;
141140
endp <-> self.endp;
142-
match streamp::client::try_data(unwrap(endp), x) {
141+
match streamp::client::try_data(endp.unwrap(), x) {
143142
Some(next) => {
144143
self.endp = Some(next);
145144
true
@@ -165,7 +164,7 @@ impl<T: Owned> GenericPort<T> for Port<T> {
165164
fn port_recv<T:Owned>(self: &Port<T>) -> T {
166165
let mut endp = None;
167166
endp <-> self.endp;
168-
let streamp::data(x, endp) = recv(unwrap(endp));
167+
let streamp::data(x, endp) = recv(endp.unwrap());
169168
self.endp = Some(endp);
170169
x
171170
}
@@ -174,7 +173,7 @@ fn port_recv<T:Owned>(self: &Port<T>) -> T {
174173
fn port_try_recv<T:Owned>(self: &Port<T>) -> Option<T> {
175174
let mut endp = None;
176175
endp <-> self.endp;
177-
match try_recv(unwrap(endp)) {
176+
match try_recv(endp.unwrap()) {
178177
Some(streamp::data(x, endp)) => {
179178
self.endp = Some(endp);
180179
Some(x)
@@ -312,7 +311,7 @@ fn shared_chan_send<T:Owned>(self: &SharedChan<T>, x: T) {
312311
do self.with_imm |chan| {
313312
let mut x = None;
314313
x <-> xx;
315-
chan.send(option::unwrap(x))
314+
chan.send(x.unwrap())
316315
}
317316
}
318317
@@ -326,7 +325,7 @@ fn shared_chan_try_send<T:Owned>(self: &SharedChan<T>, x: T) -> bool {
326325
do self.with_imm |chan| {
327326
let mut x = None;
328327
x <-> xx;
329-
chan.try_send(option::unwrap(x))
328+
chan.try_send(x.unwrap())
330329
}
331330
}
332331
@@ -409,7 +408,7 @@ pub fn try_recv_one<T: Owned> (port: PortOne<T>) -> Option<T> {
409408
410409
if message.is_none() { None }
411410
else {
412-
let oneshot::send(message) = option::unwrap(message);
411+
let oneshot::send(message) = message.unwrap();
413412
Some(message)
414413
}
415414
}

src/libcore/dlist.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use iter::BaseIter;
2323
use kinds::Copy;
2424
use managed;
2525
use option::{None, Option, Some};
26-
use option;
2726
use vec;
2827

2928
pub type DListLink<T> = Option<@mut DListNode<T>>;
@@ -377,7 +376,7 @@ pub impl<T> DList<T> {
377376
378377
/// Reverse the list's elements in place. O(n).
379378
fn reverse(@mut self) {
380-
do option::while_some(self.hd) |nobe| {
379+
do self.hd.while_some |nobe| {
381380
let next_nobe = nobe.next;
382381
self.remove(nobe);
383382
self.make_mine(nobe);
@@ -509,8 +508,8 @@ impl<T> BaseIter<T> for @mut DList<T> {
509508
*/
510509
fn each(&self, f: &fn(v: &T) -> bool) {
511510
let mut link = self.peek_n();
512-
while option::is_some(&link) {
513-
let nobe = option::get(link);
511+
while link.is_some() {
512+
let nobe = link.get();
514513
fail_unless!(nobe.linked);
515514
516515
{

0 commit comments

Comments
 (0)