Skip to content

option: rm functions that duplicate methods #5414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/compiletest/compiletest.rc
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ pub fn parse_config(args: ~[~str]) -> config {
if vec::len(matches.free) > 0u {
option::Some(matches.free[0])
} else { option::None },
logfile: option::map(&getopts::opt_maybe_str(matches,
~"logfile"),
|s| Path(*s)),
logfile: getopts::opt_maybe_str(matches, ~"logfile").map(|s| Path(*s)),
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
jit: getopts::opt_present(matches, ~"jit"),
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//! A mutable, nullable memory location

use cast::transmute;
use option;
use prelude::*;

/*
Expand Down Expand Up @@ -53,7 +52,7 @@ pub impl<T> Cell<T> {

let mut value = None;
value <-> self.value;
return option::unwrap(value);
value.unwrap()
}

/// Returns the value, failing if the cell is full.
Expand Down
17 changes: 8 additions & 9 deletions src/libcore/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Message passing
use cast;
use either::{Either, Left, Right};
use kinds::Owned;
use option;
use option::{Option, Some, None, unwrap};
use option::{Option, Some, None};
use uint;
use unstable;
use vec;
Expand Down Expand Up @@ -126,7 +125,7 @@ fn chan_send<T:Owned>(self: &Chan<T>, x: T) {
let mut endp = None;
endp <-> self.endp;
self.endp = Some(
streamp::client::data(unwrap(endp), x))
streamp::client::data(endp.unwrap(), x))
}

impl<T: Owned> GenericSmartChan<T> for Chan<T> {
Expand All @@ -139,7 +138,7 @@ impl<T: Owned> GenericSmartChan<T> for Chan<T> {
fn chan_try_send<T:Owned>(self: &Chan<T>, x: T) -> bool {
let mut endp = None;
endp <-> self.endp;
match streamp::client::try_data(unwrap(endp), x) {
match streamp::client::try_data(endp.unwrap(), x) {
Some(next) => {
self.endp = Some(next);
true
Expand All @@ -165,7 +164,7 @@ impl<T: Owned> GenericPort<T> for Port<T> {
fn port_recv<T:Owned>(self: &Port<T>) -> T {
let mut endp = None;
endp <-> self.endp;
let streamp::data(x, endp) = recv(unwrap(endp));
let streamp::data(x, endp) = recv(endp.unwrap());
self.endp = Some(endp);
x
}
Expand All @@ -174,7 +173,7 @@ fn port_recv<T:Owned>(self: &Port<T>) -> T {
fn port_try_recv<T:Owned>(self: &Port<T>) -> Option<T> {
let mut endp = None;
endp <-> self.endp;
match try_recv(unwrap(endp)) {
match try_recv(endp.unwrap()) {
Some(streamp::data(x, endp)) => {
self.endp = Some(endp);
Some(x)
Expand Down Expand Up @@ -312,7 +311,7 @@ fn shared_chan_send<T:Owned>(self: &SharedChan<T>, x: T) {
do self.with_imm |chan| {
let mut x = None;
x <-> xx;
chan.send(option::unwrap(x))
chan.send(x.unwrap())
}
}

Expand All @@ -326,7 +325,7 @@ fn shared_chan_try_send<T:Owned>(self: &SharedChan<T>, x: T) -> bool {
do self.with_imm |chan| {
let mut x = None;
x <-> xx;
chan.try_send(option::unwrap(x))
chan.try_send(x.unwrap())
}
}

Expand Down Expand Up @@ -409,7 +408,7 @@ pub fn try_recv_one<T: Owned> (port: PortOne<T>) -> Option<T> {

if message.is_none() { None }
else {
let oneshot::send(message) = option::unwrap(message);
let oneshot::send(message) = message.unwrap();
Some(message)
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/libcore/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use iter::BaseIter;
use kinds::Copy;
use managed;
use option::{None, Option, Some};
use option;
use vec;

pub type DListLink<T> = Option<@mut DListNode<T>>;
Expand Down Expand Up @@ -377,7 +376,7 @@ pub impl<T> DList<T> {

/// Reverse the list's elements in place. O(n).
fn reverse(@mut self) {
do option::while_some(self.hd) |nobe| {
do self.hd.while_some |nobe| {
let next_nobe = nobe.next;
self.remove(nobe);
self.make_mine(nobe);
Expand Down Expand Up @@ -509,8 +508,8 @@ impl<T> BaseIter<T> for @mut DList<T> {
*/
fn each(&self, f: &fn(v: &T) -> bool) {
let mut link = self.peek_n();
while option::is_some(&link) {
let nobe = option::get(link);
while link.is_some() {
let nobe = link.get();
fail_unless!(nobe.linked);

{
Expand Down
Loading