]> git.lizzy.rs Git - rust.git/commitdiff
option: rm functions that duplicate methods
authorDaniel Micay <danielmicay@gmail.com>
Sat, 16 Mar 2013 19:49:12 +0000 (15:49 -0400)
committerDaniel Micay <danielmicay@gmail.com>
Wed, 27 Mar 2013 02:44:40 +0000 (22:44 -0400)
48 files changed:
src/compiletest/compiletest.rc
src/libcore/cell.rs
src/libcore/comm.rs
src/libcore/dlist.rs
src/libcore/option.rs
src/libcore/os.rs
src/libcore/pipes.rs
src/libcore/task/local_data_priv.rs
src/libcore/task/mod.rs
src/libcore/task/spawn.rs
src/libcore/unstable.rs
src/libcore/unstable/weak_task.rs
src/libfuzzer/fuzzer.rc
src/librustc/front/config.rs
src/librustc/metadata/decoder.rs
src/librustc/middle/resolve.rs
src/librustc/middle/trans/monomorphize.rs
src/librustc/middle/trans/type_use.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/rustc.rc
src/librustdoc/attr_pass.rs
src/librustdoc/doc.rs
src/librustdoc/page_pass.rs
src/libstd/sync.rs
src/libstd/test.rs
src/libsyntax/diagnostic.rs
src/libsyntax/ext/expand.rs
src/libsyntax/fold.rs
src/test/bench/msgsend-ring-mutex-arcs.rs
src/test/bench/msgsend-ring-pipes.rs
src/test/bench/msgsend-ring-rw-arcs.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/task-perf-linked-failure.rs
src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs
src/test/compile-fail/arc-rw-state-shouldnt-escape.rs
src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs
src/test/compile-fail/issue-2766-a.rs
src/test/compile-fail/issue-3311.rs
src/test/compile-fail/sync-cond-shouldnt-escape.rs
src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs
src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs
src/test/run-pass/issue-2718.rs
src/test/run-pass/stat.rs
src/test/run-pass/task-comm-12.rs
src/test/run-pass/task-comm-9.rs
src/test/run-pass/yield.rs
src/test/run-pass/yield1.rs

index 0c1f328ad09faaaf4496f39f8a7cd457c5334406..738045705a2b5ee56b080515b4fafa5d1144d8c0 100644 (file)
@@ -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"),
index 2c29dbd2e94260140053dd52a18d1c9ece15b9f6..72beb4e017dfceb43ff57dd3fbac3b03d112e0e4 100644 (file)
@@ -11,7 +11,6 @@
 //! A mutable, nullable memory location
 
 use cast::transmute;
-use option;
 use prelude::*;
 
 /*
@@ -53,7 +52,7 @@ fn take(&self) -> T {
 
         let mut value = None;
         value <-> self.value;
-        return option::unwrap(value);
+        value.unwrap()
     }
 
     /// Returns the value, failing if the cell is full.
index f749d46bcab17e8994e34238cc45aa89689eb238..a852b0fb7208a888e42666e5439a18a2e60dbd10 100644 (file)
@@ -15,8 +15,7 @@
 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;
@@ -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> {
@@ -139,7 +138,7 @@ fn try_send(&self, x: T) -> bool {
 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
@@ -165,7 +164,7 @@ fn try_recv(&self) -> Option<T> { port_try_recv(self) }
 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
 }
@@ -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)
@@ -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())
     }
 }
 
@@ -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())
     }
 }
 
@@ -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)
     }
 }
index ff86e8d1ffcdb35c9c1338578280d4fa9293ed58..159a79129ee4c60f05f602d052fc5efb69a6cda2 100644 (file)
@@ -23,7 +23,6 @@
 use kinds::Copy;
 use managed;
 use option::{None, Option, Some};
-use option;
 use vec;
 
 pub type DListLink<T> = Option<@mut DListNode<T>>;
@@ -377,7 +376,7 @@ fn prepend(@mut self, them: @mut 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);
@@ -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);
 
             {
index bb636636953b36db36ae053a9937cd021022c172..59c836eba653fdfbd53e7b41f20071c24d3b329e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -98,218 +98,6 @@ fn add(&self, other: &Option<T>) -> Option<T> {
     }
 }
 
-#[inline(always)]
-pub fn get<T:Copy>(opt: Option<T>) -> T {
-    /*!
-    Gets the value out of an option
-
-    # Failure
-
-    Fails if the value equals `None`
-
-    # Safety note
-
-    In general, because this function may fail, its use is discouraged
-    (calling `get` on `None` is akin to dereferencing a null pointer).
-    Instead, prefer to use pattern matching and handle the `None`
-    case explicitly.
-    */
-
-    match opt {
-      Some(copy x) => return x,
-      None => fail!(~"option::get none")
-    }
-}
-
-#[inline(always)]
-pub fn get_ref<T>(opt: &'r Option<T>) -> &'r T {
-    /*!
-    Gets an immutable reference to the value inside an option.
-
-    # Failure
-
-    Fails if the value equals `None`
-
-    # Safety note
-
-    In general, because this function may fail, its use is discouraged
-    (calling `get` on `None` is akin to dereferencing a null pointer).
-    Instead, prefer to use pattern matching and handle the `None`
-    case explicitly.
-     */
-    match *opt {
-        Some(ref x) => x,
-        None => fail!(~"option::get_ref none")
-    }
-}
-
-pub fn get_mut_ref<T>(opt: &'r mut Option<T>) -> &'r mut T {
-    /*!
-    Gets a mutable reference to the value inside an option.
-
-    # Failure
-
-    Fails if the value equals `None`
-
-    # Safety note
-
-    In general, because this function may fail, its use is discouraged
-    (calling `get` on `None` is akin to dereferencing a null pointer).
-    Instead, prefer to use pattern matching and handle the `None`
-    case explicitly.
-     */
-    match *opt {
-        Some(ref mut x) => x,
-        None => fail!(~"option::get_mut_ref none")
-    }
-}
-
-#[inline(always)]
-pub fn map<T, U>(opt: &'r Option<T>, f: &fn(x: &'r T) -> U) -> Option<U> {
-    //! Maps a `some` value by reference from one type to another
-
-    match *opt { Some(ref x) => Some(f(x)), None => None }
-}
-
-#[inline(always)]
-pub fn map_consume<T, U>(opt: Option<T>,
-                              f: &fn(v: T) -> U) -> Option<U> {
-    /*!
-     * As `map`, but consumes the option and gives `f` ownership to avoid
-     * copying.
-     */
-    match opt { None => None, Some(v) => Some(f(v)) }
-}
-
-#[inline(always)]
-pub fn chain<T, U>(opt: Option<T>,
-                        f: &fn(t: T) -> Option<U>) -> Option<U> {
-    /*!
-     * Update an optional value by optionally running its content through a
-     * function that returns an option.
-     */
-
-    match opt {
-        Some(t) => f(t),
-        None => None
-    }
-}
-
-#[inline(always)]
-pub fn chain_ref<T, U>(opt: &Option<T>,
-                            f: &fn(x: &T) -> Option<U>) -> Option<U> {
-    /*!
-     * Update an optional value by optionally running its content by reference
-     * through a function that returns an option.
-     */
-
-    match *opt { Some(ref x) => f(x), None => None }
-}
-
-#[inline(always)]
-pub fn or<T>(opta: Option<T>, optb: Option<T>) -> Option<T> {
-    /*!
-     * Returns the leftmost Some() value, or None if both are None.
-     */
-    match opta {
-        Some(opta) => Some(opta),
-        _ => optb
-    }
-}
-
-#[inline(always)]
-pub fn while_some<T>(x: Option<T>, blk: &fn(v: T) -> Option<T>) {
-    //! Applies a function zero or more times until the result is none.
-
-    let mut opt = x;
-    while opt.is_some() {
-        opt = blk(unwrap(opt));
-    }
-}
-
-#[inline(always)]
-pub fn is_none<T>(opt: &const Option<T>) -> bool {
-    //! Returns true if the option equals `none`
-
-    match *opt { None => true, Some(_) => false }
-}
-
-#[inline(always)]
-pub fn is_some<T>(opt: &const Option<T>) -> bool {
-    //! Returns true if the option contains some value
-
-    !is_none(opt)
-}
-
-#[inline(always)]
-pub fn get_or_zero<T:Copy + Zero>(opt: Option<T>) -> T {
-    //! Returns the contained value or zero (for this type)
-
-    match opt { Some(copy x) => x, None => Zero::zero() }
-}
-
-#[inline(always)]
-pub fn get_or_default<T:Copy>(opt: Option<T>, def: T) -> T {
-    //! Returns the contained value or a default
-
-    match opt { Some(copy x) => x, None => def }
-}
-
-#[inline(always)]
-pub fn map_default<T, U>(opt: &'r Option<T>, def: U,
-                              f: &fn(&'r T) -> U) -> U {
-    //! Applies a function to the contained value or returns a default
-
-    match *opt { None => def, Some(ref t) => f(t) }
-}
-
-#[inline(always)]
-pub fn unwrap<T>(opt: Option<T>) -> T {
-    /*!
-    Moves a value out of an option type and returns it.
-
-    Useful primarily for getting strings, vectors and unique pointers out
-    of option types without copying them.
-
-    # Failure
-
-    Fails if the value equals `None`.
-
-    # Safety note
-
-    In general, because this function may fail, its use is discouraged.
-    Instead, prefer to use pattern matching and handle the `None`
-    case explicitly.
-     */
-    match opt {
-        Some(x) => x,
-        None => fail!(~"option::unwrap none")
-    }
-}
-
-#[inline(always)]
-pub fn swap_unwrap<T>(opt: &mut Option<T>) -> T {
-    /*!
-    The option dance. Moves a value out of an option type and returns it,
-    replacing the original with `None`.
-
-    # Failure
-
-    Fails if the value equals `None`.
-     */
-    if opt.is_none() { fail!(~"option::swap_unwrap none") }
-    unwrap(util::replace(opt, None))
-}
-
-#[inline(always)]
-pub fn expect<T>(opt: Option<T>, reason: &str) -> T {
-    //! As unwrap, but with a specified failure message.
-    match opt {
-        Some(val) => val,
-        None => fail!(reason.to_owned()),
-    }
-}
-
 impl<T> BaseIter<T> for Option<T> {
     /// Performs an operation on the contained value by reference
     #[inline(always)]
@@ -332,37 +120,64 @@ fn each_mut(&mut self, f: &fn(&'self mut T) -> bool) {
 
 pub impl<T> Option<T> {
     /// Returns true if the option equals `none`
-    #[inline(always)]
-    fn is_none(&const self) -> bool { is_none(self) }
+    fn is_none(&const self) -> bool {
+        match *self { None => true, Some(_) => false }
+    }
 
     /// Returns true if the option contains some value
     #[inline(always)]
-    fn is_some(&const self) -> bool { is_some(self) }
+    fn is_some(&const self) -> bool { !self.is_none() }
+
+    #[inline(always)]
+    fn chain<U>(self, f: &fn(t: T) -> Option<U>) -> Option<U> {
+        /*!
+         * Update an optional value by optionally running its content through a
+         * function that returns an option.
+         */
+
+        match self {
+            Some(t) => f(t),
+            None => None
+        }
+    }
+
+    #[inline(always)]
+    fn or(self, optb: Option<T>) -> Option<T> {
+        /*!
+         * Returns the leftmost Some() value, or None if both are None.
+         */
+        match self {
+            Some(opta) => Some(opta),
+            _ => optb
+        }
+    }
 
     /**
      * Update an optional value by optionally running its content by reference
      * through a function that returns an option.
      */
     #[inline(always)]
-    fn chain_ref<U>(&self, f: &fn(x: &T) -> Option<U>) -> Option<U> {
-        chain_ref(self, f)
+    fn chain_ref<U>(&self, f: &fn(x: &'self T) -> Option<U>) -> Option<U> {
+        match *self { Some(ref x) => f(x), None => None }
     }
 
     /// Maps a `some` value from one type to another by reference
     #[inline(always)]
-    fn map<U>(&self, f: &fn(&'self T) -> U) -> Option<U> { map(self, f) }
+    fn map<U>(&self, f: &fn(&'self T) -> U) -> Option<U> {
+        match *self { Some(ref x) => Some(f(x)), None => None }
+    }
 
     /// As `map`, but consumes the option and gives `f` ownership to avoid
     /// copying.
     #[inline(always)]
     fn map_consume<U>(self, f: &fn(v: T) -> U) -> Option<U> {
-        map_consume(self, f)
+        match self { None => None, Some(v) => Some(f(v)) }
     }
 
     /// Applies a function to the contained value or returns a default
     #[inline(always)]
     fn map_default<U>(&self, def: U, f: &fn(&'self T) -> U) -> U {
-        map_default(self, def, f)
+        match *self { None => def, Some(ref t) => f(t) }
     }
 
     /// As `map_default`, but consumes the option and gives `f`
@@ -403,7 +218,12 @@ fn mutate_default(&mut self, def: T, f: &fn(T) -> T) {
     case explicitly.
      */
     #[inline(always)]
-    fn get_ref(&self) -> &'self T { get_ref(self) }
+    fn get_ref(&self) -> &'self T {
+        match *self {
+          Some(ref x) => x,
+          None => fail!(~"option::get_ref none")
+        }
+    }
 
     /**
     Gets a mutable reference to the value inside an option.
@@ -420,17 +240,36 @@ fn get_ref(&self) -> &'self T { get_ref(self) }
     case explicitly.
      */
     #[inline(always)]
-    fn get_mut_ref(&mut self) -> &'self mut T { get_mut_ref(self) }
+    fn get_mut_ref(&mut self) -> &'self mut T {
+        match *self {
+          Some(ref mut x) => x,
+          None => fail!(~"option::get_mut_ref none")
+        }
+    }
 
-    /**
-     * Gets the value out of an option without copying.
-     *
-     * # Failure
-     *
-     * Fails if the value equals `none`
-     */
     #[inline(always)]
-    fn unwrap(self) -> T { unwrap(self) }
+    fn unwrap(self) -> T {
+        /*!
+        Moves a value out of an option type and returns it.
+
+        Useful primarily for getting strings, vectors and unique pointers out
+        of option types without copying them.
+
+        # Failure
+
+        Fails if the value equals `None`.
+
+        # Safety note
+
+        In general, because this function may fail, its use is discouraged.
+        Instead, prefer to use pattern matching and handle the `None`
+        case explicitly.
+         */
+        match self {
+          Some(x) => x,
+          None => fail!(~"option::unwrap none")
+        }
+    }
 
     /**
      * The option dance. Moves a value out of an option type and returns it,
@@ -441,7 +280,10 @@ fn unwrap(self) -> T { unwrap(self) }
      * Fails if the value equals `None`.
      */
     #[inline(always)]
-    fn swap_unwrap(&mut self) -> T { swap_unwrap(self) }
+    fn swap_unwrap(&mut self) -> T {
+        if self.is_none() { fail!(~"option::swap_unwrap none") }
+        util::replace(self, None).unwrap()
+    }
 
     /**
      * Gets the value out of an option, printing a specified message on
@@ -452,7 +294,12 @@ fn swap_unwrap(&mut self) -> T { swap_unwrap(self) }
      * Fails if the value equals `none`
      */
     #[inline(always)]
-    fn expect(self, reason: &str) -> T { expect(self, reason) }
+    fn expect(self, reason: &str) -> T {
+        match self {
+          Some(val) => val,
+          None => fail!(reason.to_owned()),
+        }
+    }
 }
 
 pub impl<T:Copy> Option<T> {
@@ -471,21 +318,35 @@ pub impl<T:Copy> Option<T> {
     case explicitly.
     */
     #[inline(always)]
-    fn get(self) -> T { get(self) }
+    fn get(self) -> T {
+        match self {
+          Some(copy x) => return x,
+          None => fail!(~"option::get none")
+        }
+    }
 
+    /// Returns the contained value or a default
     #[inline(always)]
-    fn get_or_default(self, def: T) -> T { get_or_default(self, def) }
+    fn get_or_default(self, def: T) -> T {
+        match self { Some(copy x) => x, None => def }
+    }
 
     /// Applies a function zero or more times until the result is none.
     #[inline(always)]
     fn while_some(self, blk: &fn(v: T) -> Option<T>) {
-        while_some(self, blk)
+        let mut opt = self;
+        while opt.is_some() {
+            opt = blk(opt.unwrap());
+        }
     }
 }
 
 pub impl<T:Copy + Zero> Option<T> {
+    /// Returns the contained value or zero (for this type)
     #[inline(always)]
-    fn get_or_zero(self) -> T { get_or_zero(self) }
+    fn get_or_zero(self) -> T {
+        match self { Some(copy x) => x, None => Zero::zero() }
+    }
 }
 
 #[test]
@@ -493,7 +354,7 @@ fn test_unwrap_ptr() {
     let x = ~0;
     let addr_x = ptr::addr_of(&(*x));
     let opt = Some(x);
-    let y = unwrap(opt);
+    let y = opt.unwrap();
     let addr_y = ptr::addr_of(&(*y));
     fail_unless!(addr_x == addr_y);
 }
@@ -503,7 +364,7 @@ fn test_unwrap_str() {
     let x = ~"test";
     let addr_x = str::as_buf(x, |buf, _len| buf);
     let opt = Some(x);
-    let y = unwrap(opt);
+    let y = opt.unwrap();
     let addr_y = str::as_buf(y, |buf, _len| buf);
     fail_unless!(addr_x == addr_y);
 }
@@ -529,7 +390,7 @@ fn R(i: @mut int) -> R {
     {
         let x = R(i);
         let opt = Some(x);
-        let _y = unwrap(opt);
+        let _y = opt.unwrap();
     }
     fail_unless!(*i == 1);
 }
@@ -540,7 +401,7 @@ fn test_option_dance() {
     let mut y = Some(5);
     let mut y2 = 0;
     for x.each |_x| {
-        y2 = swap_unwrap(&mut y);
+        y2 = y.swap_unwrap();
     }
     fail_unless!(y2 == 5);
     fail_unless!(y.is_none());
@@ -548,8 +409,8 @@ fn test_option_dance() {
 #[test] #[should_fail] #[ignore(cfg(windows))]
 fn test_option_too_much_dance() {
     let mut y = Some(util::NonCopyable());
-    let _y2 = swap_unwrap(&mut y);
-    let _y3 = swap_unwrap(&mut y);
+    let _y2 = y.swap_unwrap();
+    let _y3 = y.swap_unwrap();
 }
 
 #[test]
index 9aa00e8e4576c5b7f22d4b866de9d90bd392a41a..e93888f3eaf6ef3bf477f375e696e6e1616a5cb2 100644 (file)
@@ -517,7 +517,7 @@ fn secondary() -> Option<Path> {
 
     #[cfg(windows)]
     fn secondary() -> Option<Path> {
-        do option::chain(getenv(~"USERPROFILE")) |p| {
+        do getenv(~"USERPROFILE").chain |p| {
             if !str::is_empty(p) {
                 Some(Path(p))
             } else {
@@ -555,19 +555,16 @@ fn getenv_nonempty(v: &str) -> Option<Path> {
     #[cfg(unix)]
     #[allow(non_implicitly_copyable_typarams)]
     fn lookup() -> Path {
-        option::get_or_default(getenv_nonempty("TMPDIR"),
-                            Path("/tmp"))
+        getenv_nonempty("TMPDIR").get_or_default(Path("/tmp"))
     }
 
     #[cfg(windows)]
     #[allow(non_implicitly_copyable_typarams)]
     fn lookup() -> Path {
-        option::get_or_default(
-                    option::or(getenv_nonempty("TMP"),
-                    option::or(getenv_nonempty("TEMP"),
-                    option::or(getenv_nonempty("USERPROFILE"),
-                               getenv_nonempty("WINDIR")))),
-                    Path("C:\\Windows"))
+        getenv_nonempty("TMP").or(
+            getenv_nonempty("TEMP").or(
+                getenv_nonempty("USERPROFILE").or(
+                   getenv_nonempty("WINDIR")))).get_or_default(Path("C:\\Windows"))
     }
 }
 /// Recursively walk a directory structure
index 350a1de629cd4d370ca22a6c78354e35b803ca5b..ae01a3d57f34741363a425a272134c90a6ee9bcc 100644 (file)
@@ -87,8 +87,7 @@
 use either::{Either, Left, Right};
 use kinds::Owned;
 use libc;
-use option;
-use option::{None, Option, Some, unwrap};
+use option::{None, Option, Some};
 use unstable::intrinsics;
 use ptr;
 use task;
@@ -465,7 +464,7 @@ struct DropState {
         let mut payload = None;
         payload <-> p.payload;
         p.header.state = Empty;
-        return Some(option::unwrap(payload))
+        return Some(payload.unwrap())
       },
       Terminated => return None,
       _ => {}
@@ -523,7 +522,7 @@ struct DropState {
                 }
             }
             p.header.state = Empty;
-            return Some(option::unwrap(payload))
+            return Some(payload.unwrap())
           }
           Terminated => {
             // This assert detects when we've accidentally unsafely
@@ -777,7 +776,7 @@ fn finalize(&self) {
         if self.p != None {
             let mut p = None;
             p <-> self.p;
-            sender_terminate(option::unwrap(p))
+            sender_terminate(p.unwrap())
         }
         //unsafe { error!("send_drop: %?",
         //                if self.buffer == none {
@@ -802,7 +801,7 @@ pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
     fn unwrap(&self) -> *Packet<T> {
         let mut p = None;
         p <-> self.p;
-        option::unwrap(p)
+        p.unwrap()
     }
 
     fn header(&self) -> *PacketHeader {
@@ -821,7 +820,7 @@ fn reuse_buffer(&self) -> BufferResource<Tbuffer> {
         //error!("send reuse_buffer");
         let mut tmp = None;
         tmp <-> self.buffer;
-        option::unwrap(tmp)
+        tmp.unwrap()
     }
 }
 
@@ -847,7 +846,7 @@ fn finalize(&self) {
         if self.p != None {
             let mut p = None;
             p <-> self.p;
-            receiver_terminate(option::unwrap(p))
+            receiver_terminate(p.unwrap())
         }
         //unsafe { error!("recv_drop: %?",
         //                if self.buffer == none {
@@ -860,14 +859,14 @@ pub impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
     fn unwrap(&self) -> *Packet<T> {
         let mut p = None;
         p <-> self.p;
-        option::unwrap(p)
+        p.unwrap()
     }
 
     fn reuse_buffer(&self) -> BufferResource<Tbuffer> {
         //error!("recv reuse_buffer");
         let mut tmp = None;
         tmp <-> self.buffer;
-        option::unwrap(tmp)
+        tmp.unwrap()
     }
 }
 
index 59f4942b3a4a7396c40771f63e7698e389e40abe..a4fd18ec09430e322f8c570428827e59daab3f2b 100644 (file)
@@ -13,7 +13,6 @@
 use cast;
 use cmp::Eq;
 use libc;
-use option;
 use prelude::*;
 use task::rt;
 use task::local_data::LocalDataKey;
@@ -181,6 +180,6 @@ pub unsafe fn local_modify<T:Durable>(
     // Could be more efficient by doing the lookup work, but this is easy.
     let newdata = modify_fn(local_pop(task, key));
     if newdata.is_some() {
-        local_set(task, key, option::unwrap(newdata));
+        local_set(task, key, newdata.unwrap());
     }
 }
index 349a10bb809830f4dc36d6f8fb719883679128bf..3e980daaa08deb75cffc1963a3d8b6ab5dbe50e9 100644 (file)
@@ -35,7 +35,6 @@
 
 use cell::Cell;
 use cmp::Eq;
-use option;
 use result::Result;
 use comm::{stream, Chan, GenericChan, GenericPort, Port, SharedChan};
 use prelude::*;
@@ -410,7 +409,7 @@ fn try<T:Owned>(&self, f: ~fn() -> T) -> Result<T,()> {
         do fr_task_builder.spawn || {
             ch.send(f());
         }
-        match option::unwrap(result).recv() {
+        match result.unwrap().recv() {
             Success => result::Ok(po.recv()),
             Failure => result::Err(())
         }
@@ -839,14 +838,14 @@ fn test_add_wrapper() {
 fn test_future_result() {
     let mut result = None;
     do task().future_result(|+r| { result = Some(r); }).spawn { }
-    fail_unless!(option::unwrap(result).recv() == Success);
+    fail_unless!(result.unwrap().recv() == Success);
 
     result = None;
     do task().future_result(|+r|
         { result = Some(r); }).unlinked().spawn {
         fail!();
     }
-    fail_unless!(option::unwrap(result).recv() == Failure);
+    fail_unless!(result.unwrap().recv() == Failure);
 }
 
 #[test] #[should_fail] #[ignore(cfg(windows))]
index b97a682c4e5caf1d1715e231a113a6f4643b57f4..f353db5ae7098099bfa92797fdcaf841c85af7ac 100644 (file)
@@ -75,7 +75,6 @@
 use cast;
 use cell::Cell;
 use container::Map;
-use option;
 use comm::{Chan, GenericChan, GenericPort, Port, stream};
 use prelude::*;
 use unstable;
@@ -194,7 +193,7 @@ fn coalesce(list:            &mut AncestorList,
         if coalesce_this.is_some() {
             // Needed coalesce. Our next ancestor becomes our old
             // ancestor's next ancestor. ("next = old_next->next;")
-            *list = option::unwrap(coalesce_this);
+            *list = coalesce_this.unwrap();
         } else {
             // No coalesce; restore from tmp. ("next = old_next;")
             *list = tmp_list;
@@ -290,7 +289,7 @@ fn iterate(ancestors:       &AncestorList,
         fn with_parent_tg<U>(parent_group: &mut Option<TaskGroupArc>,
                              blk: &fn(TaskGroupInner) -> U) -> U {
             // If this trips, more likely the problem is 'blk' failed inside.
-            let tmp_arc = option::swap_unwrap(&mut *parent_group);
+            let tmp_arc = parent_group.swap_unwrap();
             let result = do access_group(&tmp_arc) |tg_opt| { blk(tg_opt) };
             *parent_group = Some(tmp_arc);
             result
@@ -374,7 +373,7 @@ fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task,
     let newstate = util::replace(&mut *state, None);
     // If 'None', the group was failing. Can't enlist.
     if newstate.is_some() {
-        let group = option::unwrap(newstate);
+        let group = newstate.unwrap();
         taskset_insert(if is_member { &mut group.members }
                        else         { &mut group.descendants }, me);
         *state = Some(group);
@@ -390,7 +389,7 @@ fn leave_taskgroup(state: TaskGroupInner, me: *rust_task,
     let newstate = util::replace(&mut *state, None);
     // If 'None', already failing and we've already gotten a kill signal.
     if newstate.is_some() {
-        let group = option::unwrap(newstate);
+        let group = newstate.unwrap();
         taskset_remove(if is_member { &mut group.members }
                        else         { &mut group.descendants }, me);
         *state = Some(group);
@@ -414,7 +413,7 @@ fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) {
         // That's ok; only one task needs to do the dirty work. (Might also
         // see 'None' if Somebody already failed and we got a kill signal.)
         if newstate.is_some() {
-            let group = option::unwrap(newstate);
+            let group = newstate.unwrap();
             for taskset_each(&group.members) |sibling| {
                 // Skip self - killing ourself won't do much good.
                 if sibling != me {
@@ -519,7 +518,7 @@ fn share_ancestors(ancestors: &mut AncestorList) -> AncestorList {
         //    None               { ancestor_list(None) }
         let tmp = util::replace(&mut **ancestors, None);
         if tmp.is_some() {
-            let ancestor_arc = option::unwrap(tmp);
+            let ancestor_arc = tmp.unwrap();
             let result = ancestor_arc.clone();
             **ancestors = Some(ancestor_arc);
             AncestorList(Some(result))
@@ -549,7 +548,7 @@ pub fn spawn_raw(opts: TaskOpts, f: ~fn()) {
             let mut notify_chan = if opts.notify_chan.is_none() {
                 None
             } else {
-                Some(option::swap_unwrap(&mut opts.notify_chan))
+                Some(opts.notify_chan.swap_unwrap())
             };
 
             let child_wrapper = make_child_wrapper(new_task, child_tg,
index 6f0c9ba23dfd5e45a185215cd2ad13510082f33a..5daccd9f879f4954c37c41fe893d90797e117a68 100644 (file)
@@ -12,7 +12,6 @@
 
 use cast;
 use libc;
-use option;
 use comm::{GenericChan, GenericPort};
 use prelude::*;
 use task;
@@ -165,7 +164,7 @@ pub unsafe fn get_shared_mutable_state<T:Owned>(
     unsafe {
         let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
         fail_unless!(ptr.count > 0);
-        let r = cast::transmute(option::get_ref(&ptr.data));
+        let r = cast::transmute(ptr.data.get_ref());
         cast::forget(ptr);
         return r;
     }
@@ -177,7 +176,7 @@ pub unsafe fn get_shared_immutable_state<T:Owned>(
         let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
         fail_unless!(ptr.count > 0);
         // Cast us back into the correct region
-        let r = cast::transmute_region(option::get_ref(&ptr.data));
+        let r = cast::transmute_region(ptr.data.get_ref());
         cast::forget(ptr);
         return r;
     }
index 7e9742fecbba461a4894b7acf764c9ceeaa0917b..1947f294cb3d36fa8368bc4307a0db925abab564 100644 (file)
@@ -22,7 +22,7 @@
 use comm::{GenericSmartChan, stream};
 use comm::{Port, Chan, SharedChan, GenericChan, GenericPort};
 use hashmap::linear::LinearMap;
-use option::{Some, None, swap_unwrap};
+use option::{Some, None};
 use unstable::at_exit::at_exit;
 use unstable::finally::Finally;
 use unstable::global::global_data_clone_create;
index 3580edb58146221dba617e14367ecc35c4be90ce..cb9e4a4d7b8f6c91f209ddc8d65465c0f5e43972 100644 (file)
@@ -334,8 +334,8 @@ pub fn check_variants_T<T: Copy>(
 }
 
 pub fn last_part(filename: ~str) -> ~str {
-  let ix = option::get(str::rfind_char(filename, '/'));
-  str::slice(filename, ix + 1u, str::len(filename) - 3u).to_owned()
+    let ix = str::rfind_char(filename, '/').get();
+    str::slice(filename, ix + 1u, str::len(filename) - 3u).to_owned()
 }
 
 pub enum happiness {
index 39a1fda2c92962c8a8289cfb9a0de94d2b18a44b..2cec6ec5ab1218734ba8a7848cf65cca46bda55f 100644 (file)
@@ -142,7 +142,7 @@ fn fold_block(
     ast::blk_ {
         view_items: /*bad*/copy b.view_items,
         stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)),
-        expr: option::map(&b.expr, |x| fld.fold_expr(*x)),
+        expr: b.expr.map(|x| fld.fold_expr(*x)),
         id: b.id,
         rules: b.rules,
     }
index 0e9246eedbc8734395fec772e826b04b18777869..5f74dcb27ac603d60e4a5a79075db23538982f8b 100644 (file)
@@ -207,8 +207,7 @@ fn each_reexport(d: ebml::Doc, f: &fn(ebml::Doc) -> bool) {
 
 fn field_mutability(d: ebml::Doc) -> ast::struct_mutability {
     // Use maybe_get_doc in case it's a method
-    option::map_default(
-        &reader::maybe_get_doc(d, tag_struct_mut),
+    reader::maybe_get_doc(d, tag_struct_mut).map_default(
         ast::struct_immutable,
         |d| {
             match reader::doc_as_u8(*d) as char {
@@ -219,7 +218,7 @@ fn field_mutability(d: ebml::Doc) -> ast::struct_mutability {
 }
 
 fn variant_disr_val(d: ebml::Doc) -> Option<int> {
-    do option::chain(reader::maybe_get_doc(d, tag_disr_val)) |val_doc| {
+    do reader::maybe_get_doc(d, tag_disr_val).chain |val_doc| {
         int::parse_bytes(reader::doc_data(val_doc), 10u)
     }
 }
index f956c8cb10c124d4ee54ec692bbbf45761a8fa1c..bd507f4cf22891250f35d6b9650a5aaed3d52c09 100644 (file)
@@ -75,7 +75,6 @@
 use syntax::visit::{visit_mod, visit_ty, vt};
 use syntax::opt_vec::OptVec;
 
-use core::option::{Some, get, is_some, is_none};
 use core::str::{connect, each_split_str};
 use core::hashmap::linear::{LinearMap, LinearSet};
 
@@ -2490,7 +2489,7 @@ fn resolve_glob_import(@mut self,
 
             debug!("(resolving glob import) writing module resolution \
                     %? into `%s`",
-                   is_none(&mut target_import_resolution.type_target),
+                   target_import_resolution.type_target.is_none(),
                    self.module_to_str(module_));
 
             // Here we merge two import resolutions.
@@ -5163,7 +5162,7 @@ fn check_duplicate_main(@mut self) {
             if this.main_fns.len() >= 1u {
                 let mut i = 1u;
                 while i < this.main_fns.len() {
-                    let (_, dup_main_span) = option::unwrap(this.main_fns[i]);
+                    let (_, dup_main_span) = this.main_fns[i].unwrap();
                     this.session.span_err(
                         dup_main_span,
                         ~"multiple 'main' functions");
index 659b3f6c7acc3b08145cfadb7eaf2ac7465578e2..e8c6cf78a187ab149e904e420e5719b3f4cd037b 100644 (file)
@@ -32,7 +32,6 @@
 use middle::typeck;
 use util::ppaux::ty_to_str;
 
-use core::option;
 use core::vec;
 use syntax::ast;
 use syntax::ast_map;
@@ -194,8 +193,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
       }
       ast_map::node_variant(ref v, enum_item, _) => {
         let tvs = ty::enum_variants(ccx.tcx, local_def(enum_item.id));
-        let this_tv = option::get(vec::find(*tvs, |tv| {
-            tv.id.node == fn_id.node}));
+        let this_tv = vec::find(*tvs, |tv| { tv.id.node == fn_id.node}).get();
         let d = mk_lldecl();
         set_inline_hint(d);
         match (*v).node.kind {
@@ -248,9 +246,8 @@ pub fn monomorphic_fn(ccx: @CrateContext,
         set_inline_hint(d);
         base::trans_tuple_struct(ccx,
                                  /*bad*/copy struct_def.fields,
-                                 option::expect(struct_def.ctor_id,
-                                                ~"ast-mapped tuple struct \
-                                                  didn't have a ctor id"),
+                                 struct_def.ctor_id.expect(~"ast-mapped tuple struct \
+                                                             didn't have a ctor id"),
                                  psubsts,
                                  d);
         d
index e19afb0d5077d8862ba5c6122612f21d8941af01..cad2a03f7a1ef8143c74c0329ce83013dac396a2 100644 (file)
@@ -35,7 +35,6 @@
 use middle::ty;
 use middle::typeck;
 
-use core::option;
 use core::option::{Some, None, Option};
 use core::uint;
 use core::vec;
@@ -220,7 +219,7 @@ pub fn type_needs_inner(cx: Context,
                 ty::ty_trait(_, _, _) => false,
 
               ty::ty_enum(did, ref substs) => {
-                if option::is_none(&list::find(enums_seen, |id| *id == did)) {
+                if list::find(enums_seen, |id| *id == did).is_none() {
                     let seen = @Cons(did, enums_seen);
                     for vec::each(*ty::enum_variants(cx.ccx.tcx, did)) |v| {
                         for vec::each(v.args) |aty| {
index fcbf34dca905429492a5264039d96be4bfa18bff..edf76ee7c36396666e756256129adde58b058e4d 100644 (file)
@@ -30,7 +30,6 @@
 use core::cast;
 use core::cmp;
 use core::ops;
-use core::option;
 use core::ptr::to_unsafe_ptr;
 use core::result::Result;
 use core::result;
@@ -3632,11 +3631,10 @@ fn storeify(cx: ctxt, ty: t, store: TraitStore) -> t {
                         _},
                     _)) => {
 
-               do option::map_default(&opt_trait, ~[]) |trait_ref| {
-                       ~[storeify(cx,
-                                  node_id_to_type(cx, trait_ref.ref_id),
-                                  store)]
-                   }
+               do opt_trait.map_default(~[]) |trait_ref| {
+                   ~[storeify(cx, node_id_to_type(cx, trait_ref.ref_id),
+                              store)]
+               }
            }
            _ => ~[]
         }
index 005b5377b629ef75aa06f2f56881ede8402a328c..17a67838bbe8befdb521265174e5cf22cce1f1cd 100644 (file)
 
 use core::either;
 use core::hashmap::linear::LinearMap;
-use core::option;
 use core::ptr;
 use core::result::{Result, Ok, Err};
 use core::result;
@@ -319,7 +318,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
     debug!("check_fn(arg_tys=%?, ret_ty=%?, self_info.self_ty=%?)",
            arg_tys.map(|a| ppaux::ty_to_str(tcx, *a)),
            ppaux::ty_to_str(tcx, ret_ty),
-           option::map(&self_info, |s| ppaux::ty_to_str(tcx, s.self_ty)));
+           self_info.map(|s| ppaux::ty_to_str(tcx, s.self_ty)));
 
     // ______________________________________________________________________
     // Create the function context.  This is either derived from scratch or,
index f26a97b48a1ff09e0c808e24b51aa1d20e5fa34f..5b4d3be1264618d42c0968ef69fa1638a62b34ea 100644 (file)
@@ -260,10 +260,8 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
     let ofile = getopts::opt_maybe_str(matches, ~"o");
     let ofile = ofile.map(|o| Path(*o));
     let cfg = build_configuration(sess, binary, input);
-    let pretty =
-        option::map(&getopts::opt_default(matches, ~"pretty",
-                                         ~"normal"),
-                    |a| parse_pretty(sess, *a) );
+    let pretty = getopts::opt_default(matches, ~"pretty", "normal").map(
+                    |a| parse_pretty(sess, *a));
     match pretty {
       Some::<pp_mode>(ppm) => {
         pretty_print_input(sess, cfg, input, ppm);
index 30c8ff6964ef8bf7af1a4de7e1010060f58ecc2a..101c11bd58b36595ae40daeb35090f470ac8141b 100644 (file)
@@ -27,7 +27,6 @@
 use fold;
 use pass::Pass;
 
-use core::option;
 use core::vec;
 use syntax::ast;
 use syntax::ast_map;
@@ -71,8 +70,7 @@ fn fold_crate(
     doc::CrateDoc {
         topmod: doc::ModDoc {
             item: doc::ItemDoc {
-                name: option::get_or_default(copy attrs.name,
-                                             doc.topmod.name()),
+                name: (copy attrs.name).get_or_default(doc.topmod.name()),
                 .. copy doc.topmod.item
             },
             .. copy doc.topmod
@@ -166,10 +164,10 @@ fn fold_enum(
                         ast_map::node_item(@ast::item {
                             node: ast::item_enum(ref enum_definition, _), _
                         }, _) => {
-                            let ast_variant = option::get(
+                            let ast_variant =
                                 vec::find(enum_definition.variants, |v| {
                                     to_str(v.node.name) == variant.name
-                                }));
+                                }).get();
 
                             attr_parser::parse_desc(
                                 copy ast_variant.node.attrs)
index 5eecbf58cc6530a534d926ef51f686032e9a0ff3..2d5f60e714b5082511c9697d7d534ca9498c063f 100644 (file)
@@ -14,7 +14,6 @@
 
 use doc;
 
-use core::option;
 use core::vec;
 
 pub type AstId = int;
@@ -175,12 +174,12 @@ pub struct IndexEntry {
 
 pub impl Doc {
     fn CrateDoc(&self) -> CrateDoc {
-        option::get(vec::foldl(None, self.pages, |_m, page| {
+        vec::foldl(None, self.pages, |_m, page| {
             match copy *page {
               doc::CratePage(doc) => Some(doc),
               _ => None
             }
-        }))
+        }).get()
     }
 
     fn cratemod(&self) -> ModDoc {
index d5e877de71253b3deaf33cad2730ff87d3e0bcb0..49db98e32006fd876393832a9c30814093b24ba9 100644 (file)
@@ -26,7 +26,6 @@
 use pass::Pass;
 use util::NominalOp;
 
-use core::option;
 use core::comm::*;
 use syntax::ast;
 
@@ -68,7 +67,7 @@ fn make_doc_from_pages(page_port: &PagePort) -> doc::Doc {
     loop {
         let val = page_port.recv();
         if val.is_some() {
-            pages += ~[option::unwrap(val)];
+            pages += ~[val.unwrap()];
         } else {
             break;
         }
index 569c67eac93fb5a933ffb128792aa1f163229d2a..22ba33ba04e43b5be5c22fbfbd4a6f5a92838d0d 100644 (file)
@@ -15,7 +15,6 @@
  * in std.
  */
 
-use core::option;
 use core::prelude::*;
 use core::unstable::{Exclusive, exclusive};
 use core::ptr;
@@ -119,7 +118,7 @@ fn acquire(&self) {
         /* for 1000.times { task::yield(); } */
         // Need to wait outside the exclusive.
         if waiter_nobe.is_some() {
-            let _ = comm::recv_one(option::unwrap(waiter_nobe));
+            let _ = comm::recv_one(waiter_nobe.unwrap());
         }
     }
     fn release(&self) {
@@ -235,7 +234,7 @@ fn wait_on(&self, condvar_id: uint) {
                             signal_waitqueue(&state.waiters);
                         }
                         // Enqueue ourself to be woken up by a signaller.
-                        let SignalEnd = option::swap_unwrap(&mut SignalEnd);
+                        let SignalEnd = SignalEnd.swap_unwrap();
                         state.blocked[condvar_id].tail.send(SignalEnd);
                     } else {
                         out_of_bounds = Some(vec::len(state.blocked));
@@ -255,7 +254,7 @@ fn wait_on(&self, condvar_id: uint) {
             // Unconditionally "block". (Might not actually block if a
             // signaller already sent -- I mean 'unconditionally' in contrast
             // with acquire().)
-            let _ = comm::recv_one(option::swap_unwrap(&mut WaitEnd));
+            let _ = comm::recv_one(WaitEnd.swap_unwrap());
         }
 
         // This is needed for a failing condition variable to reacquire the
@@ -327,7 +326,7 @@ fn broadcast_on(&self, condvar_id: uint) -> uint {
             }
         }
         do check_cvar_bounds(out_of_bounds, condvar_id, "cond.signal_on()") {
-            let queue = option::swap_unwrap(&mut queue);
+            let queue = queue.swap_unwrap();
             broadcast_waitqueue(&queue)
         }
     }
@@ -1352,7 +1351,7 @@ pub fn test_rwlock_downgrade_cant_swap() {
         do x.write_downgrade |xwrite| {
             let mut xopt = Some(xwrite);
             do y.write_downgrade |_ywrite| {
-                y.downgrade(option::swap_unwrap(&mut xopt));
+                y.downgrade(xopt.swap_unwrap());
                 error!("oops, y.downgrade(x) should have failed!");
             }
         }
index d039e8eef5aa6bb9724a8fda9647ad9e69e047cb..ded4d6fd1b4dc59611c0db09fc381a88e17ca948 100644 (file)
@@ -569,7 +569,7 @@ fn run_test_inner(desc: TestDesc,
             task::task().unlinked().future_result(|+r| {
                 result_future = Some(r);
             }).spawn(testfn_cell.take());
-            let task_result = option::unwrap(result_future).recv();
+            let task_result = result_future.unwrap().recv();
             let test_result = calc_result(&desc,
                                           task_result == task::Success);
             monitor_ch.send((desc, test_result));
index eed36e16754f5855d4498d8fbf5af1181320d6a3..24360734520e3420f9f483dc892b08187ed94563 100644 (file)
@@ -15,7 +15,6 @@
 
 use core::io::WriterUtil;
 use core::io;
-use core::option;
 use core::str;
 use core::vec;
 
@@ -294,8 +293,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
 
 fn print_macro_backtrace(cm: @codemap::CodeMap, sp: span) {
     for sp.expn_info.each |ei| {
-        let ss = option::map_default(&ei.callee.span, @~"",
-                                     |span| @cm.span_to_str(*span));
+        let ss = ei.callee.span.map_default(@~"", |span| @cm.span_to_str(*span));
         print_diagnostic(*ss, note,
                          fmt!("in expansion of %s!", ei.callee.name));
         let ss = cm.span_to_str(ei.call_site);
index fb9d96a783174142f5bcfe2634054bb194687fa7..07ed6b7dfe28d9bb3aa0d805fc8072c7de4edb4c 100644 (file)
@@ -22,7 +22,6 @@
 use parse;
 use parse::{parser, parse_item_from_source_str, new_parser_from_tts};
 
-use core::option;
 use core::vec;
 
 pub fn expand_expr(extsbox: @mut SyntaxEnv,
@@ -294,8 +293,7 @@ pub fn expand_item_mac(+extsbox: @mut SyntaxEnv,
         MRExpr(_) => cx.span_fatal(pth.span,
                                     ~"expr macro in item position: "
                                     + *extname),
-        MRAny(_, item_maker, _) =>
-            option::chain(item_maker(), |i| {fld.fold_item(i)}),
+        MRAny(_, item_maker, _) => item_maker().chain(|i| {fld.fold_item(i)}),
         MRDef(ref mdef) => {
             extsbox.insert(@/*bad*/ copy mdef.name, @SE((*mdef).ext));
             None
index 159b23f4f9997d70227cc51699ba261e1868a43d..b3974acc6741a08825cc2e856c1ebc349b0d35ab 100644 (file)
@@ -15,7 +15,6 @@
 use codemap::{span, spanned};
 use opt_vec::OptVec;
 
-use core::option;
 use core::vec;
 
 pub trait ast_fold {
@@ -298,7 +297,7 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ {
 
 fn fold_struct_def(struct_def: @ast::struct_def, fld: @ast_fold)
                 -> @ast::struct_def {
-    let dtor = do option::map(&struct_def.dtor) |dtor| {
+    let dtor = do struct_def.dtor.map |dtor| {
         let dtor_body = fld.fold_block(&dtor.node.body);
         let dtor_id   = fld.new_id(dtor.node.id);
         spanned {
@@ -663,7 +662,7 @@ fn fold_variant_arg_(va: variant_arg, fld: @ast_fold) -> variant_arg {
             })
         }
         struct_variant_kind(struct_def) => {
-            let dtor = do option::map(&struct_def.dtor) |dtor| {
+            let dtor = do struct_def.dtor.map |dtor| {
                 let dtor_body = fld.fold_block(&dtor.node.body);
                 let dtor_id   = fld.new_id(dtor.node.id);
                 spanned {
@@ -679,7 +678,7 @@ fn fold_variant_arg_(va: variant_arg, fld: @ast_fold) -> variant_arg {
                 fields: vec::map(struct_def.fields,
                                  |f| fld.fold_struct_field(*f)),
                 dtor: dtor,
-                ctor_id: option::map(&struct_def.ctor_id, |c| fld.new_id(*c))
+                ctor_id: struct_def.ctor_id.map(|c| fld.new_id(*c))
             })
         }
         enum_variant_kind(ref enum_definition) => {
index 12060a87850a0bbd3fbf0159cb2665bb6d9bdb60..a1ab7384d62a5bb3ba4d9c5e50de3c0b3d42d2b5 100644 (file)
@@ -54,8 +54,8 @@ fn thread_ring(i: uint,
     // Send/Receive lots of messages.
     for uint::range(0u, count) |j| {
         //error!("task %?, iter %?", i, j);
-        let mut num_chan2 = option::swap_unwrap(&mut num_chan);
-        let mut num_port2 = option::swap_unwrap(&mut num_port);
+        let mut num_chan2 = num_chan.swap_unwrap();
+        let mut num_port2 = num_port.swap_unwrap();
         send(&num_chan2, i * j);
         num_chan = Some(num_chan2);
         let _n = recv(&num_port2);
index 56a46d3e006cc2cdedc0df5948d61e4b50eec6ad..1fdc826c48109fc6d90e348ac4ffd137c9329a7b 100644 (file)
@@ -46,8 +46,8 @@ fn thread_ring(i: uint,
         let mut num_port2 = None;
         num_chan2 <-> num_chan;
         num_port2 <-> num_port;
-        num_chan = Some(ring::client::num(option::unwrap(num_chan2), i * j));
-        let port = option::unwrap(num_port2);
+        num_chan = Some(ring::client::num(num_chan2.unwrap(), i * j));
+        let port = num_port2.unwrap();
         match recv(port) {
           ring::num(_n, p) => {
             //log(error, _n);
index 57d04abb414c135fb4fe47fd85267eb88a001521..8e819cc4aba00f19234dfcbec436c07a6228c2e4 100644 (file)
@@ -55,8 +55,8 @@ fn thread_ring(i: uint,
     // Send/Receive lots of messages.
     for uint::range(0u, count) |j| {
         //error!("task %?, iter %?", i, j);
-        let mut num_chan2 = option::swap_unwrap(&mut num_chan);
-        let mut num_port2 = option::swap_unwrap(&mut num_port);
+        let mut num_chan2 = num_chan.swap_unwrap();
+        let mut num_port2 = num_port.swap_unwrap();
         send(&num_chan2, i * j);
         num_chan = Some(num_chan2);
         let _n = recv(&num_port2);
index f4ae799aace703facca44bd2e67d9e0ffbe29fea..3bc40a46cfb2c1f87d2604c214a121a1e5a917c6 100644 (file)
@@ -158,7 +158,7 @@ fn main() {
         let sz = *sz;
         let mut stream = None;
         stream <-> streams[ii];
-        let (from_child_, to_parent_) = option::unwrap(stream);
+        let (from_child_, to_parent_) = stream.unwrap();
 
         from_child.push(from_child_);
 
index de58ae8ab0d3a24ecfa5834fd02e124799f1dd67..889a2836c0ca9178a4fb02857bcab88562e2d59e 100644 (file)
@@ -50,7 +50,7 @@ fn spawn_supervised_blocking(myname: &str, +f: ~fn()) {
     let mut res = None;
     task::task().future_result(|+r| res = Some(r)).supervised().spawn(f);
     error!("%s group waiting", myname);
-    let x = option::unwrap(res).recv();
+    let x = res.unwrap().recv();
     fail_unless!(x == task::Success);
 }
 
index 7d74d7039a8f07eb71038fb8715d996dcb9b14a5..f59eb509156ac040054abceb03365e4e0613d8c6 100644 (file)
@@ -17,5 +17,5 @@ fn main() {
     do x.write_cond |_one, cond| {
         y = Some(cond);
     }
-    option::unwrap(y).wait();
+    y.unwrap().wait();
 }
index b9f0fb18c16a132383c89235d1ddbdadd155abbb..22f5a8eac03d2f99035e642be50fd1bd4419455c 100644 (file)
@@ -17,5 +17,5 @@ fn main() {
     do x.write |one| {
         y = Some(one);
     }
-    *option::unwrap(y) = 2;
+    *y.unwrap() = 2;
 }
index 828bd0a4dc60f9cf3931ef4103b22b36204e1752..c8273cb016797bca8bb8ebfbe6116e2dc58bc2a9 100644 (file)
@@ -19,5 +19,5 @@ fn main() {
             y = Some(cond);
         }
     }
-    option::unwrap(y).wait();
+    y.unwrap().wait();
 }
index 8ec63ddc634c5892eec5c2c7c1a3f5c8751ad9e6..5e3eb9ef09bc6a24aaef394a820dc090bd7ab419 100644 (file)
@@ -22,7 +22,7 @@ pub fn recv(+pipe: Stream<T>) -> ::stream::Stream<T> { //~ ERROR attempt to use
                 //~^ ERROR use of undeclared type name
                 //~^^ ERROR attempt to use a type argument out of scope
                 //~^^^ ERROR use of undeclared type name
-                    option::unwrap(pipes::recv(pipe))
+                    pipes::recv(pipe).unwrap()
                 }
                 recv
             }
index 1b83cefbf33988fd9fb13d634531ddac756b4d53..295b6c989b5f3028b33efa0e287319a35d2c8fc1 100644 (file)
@@ -26,6 +26,6 @@ fn bar(s: &str, f: &fn(Option<Foo>)) {
 
 fn main() {
     do bar(~"testing") |opt| {
-        io::println(option::unwrap(opt).get_s()); //~ ERROR illegal borrow:
+        io::println(opt.unwrap().get_s()); //~ ERROR illegal borrow:
     };
 }
index 1fc90f3ba9d803041dfbe77035e8443f358910ae..964c2ce946b473acf6ff9f2c28bf4cd730847111 100644 (file)
@@ -17,6 +17,6 @@ fn main() {
     let mut cond = None;
     do m.lock_cond |c| {
         cond = Some(c);
-    }   
-    option::unwrap(cond).signal();
+    }
+    cond.unwrap().signal();
 }
index a02a2758fb94d39deb812365f7e6ded933484fa1..9cab2d3b056260fd123b6e5b4412acc196142a2d 100644 (file)
@@ -17,5 +17,5 @@ fn main() {
     do x.write_cond |cond| {
         y = Some(cond);
     }
-    option::unwrap(y).wait();
+    y.unwrap().wait();
 }
index 2421209902b4a9b8bdab492ec7b98f51cb92af37..43ad693ccf8d8492e5b8128ac54412d776577df7 100644 (file)
@@ -19,5 +19,5 @@ fn main() {
             y = Some(cond);
         }
     }
-    option::unwrap(y).wait();
+    y.unwrap().wait();
 }
index cc4f10ca347b48ceff253292e19355127049afe2..3acfa74411721442c5a2af0d02598af8c6bda680 100644 (file)
@@ -107,7 +107,7 @@ pub fn recv<T:Owned>(mut p: recv_packet<T>) -> Option<T> {
               full => {
                 let mut payload = None;
                 payload <-> (*p).payload;
-                return Some(option::unwrap(payload))
+                return Some(payload.unwrap())
               }
               terminated => {
                 fail_unless!(old_state == terminated);
@@ -164,7 +164,7 @@ fn finalize(&self) {
                     let self_p: &mut Option<*packet<T>> =
                         cast::transmute(&self.p);
                     p <-> *self_p;
-                    sender_terminate(option::unwrap(p))
+                    sender_terminate(p.unwrap())
                 }
             }
         }
@@ -174,7 +174,7 @@ pub impl<T:Owned> send_packet<T> {
         fn unwrap(&mut self) -> *packet<T> {
             let mut p = None;
             p <-> self.p;
-            option::unwrap(p)
+            p.unwrap()
         }
     }
 
@@ -197,7 +197,7 @@ fn finalize(&self) {
                     let self_p: &mut Option<*packet<T>> =
                         cast::transmute(&self.p);
                     p <-> *self_p;
-                    receiver_terminate(option::unwrap(p))
+                    receiver_terminate(p.unwrap())
                 }
             }
         }
@@ -207,7 +207,7 @@ pub impl<T:Owned> recv_packet<T> {
         fn unwrap(&mut self) -> *packet<T> {
             let mut p = None;
             p <-> self.p;
-            option::unwrap(p)
+            p.unwrap()
         }
     }
 
@@ -275,7 +275,7 @@ pub fn do_pong(+c: pong) -> (ping, ()) {
             if packet.is_none() {
                 fail!(~"sender closed the connection")
             }
-            (pingpong::liberate_pong(option::unwrap(packet)), ())
+            (pingpong::liberate_pong(packet.unwrap()), ())
         }
     }
 
@@ -290,7 +290,7 @@ pub fn do_ping(+c: ping) -> (pong, ()) {
             if packet.is_none() {
                 fail!(~"sender closed the connection")
             }
-            (pingpong::liberate_ping(option::unwrap(packet)), ())
+            (pingpong::liberate_ping(packet.unwrap()), ())
         }
 
         pub fn do_pong(+c: pong) -> ping {
index f2e12294b0988f4a2c128f0f274b30eed700cc05..6b3a37a9d79515b9d818e0af0905915215a80f27 100644 (file)
@@ -15,7 +15,7 @@
 use std::tempfile;
 
 pub fn main() {
-    let dir = option::unwrap(tempfile::mkdtemp(&Path("."), ""));
+    let dir = tempfile::mkdtemp(&Path("."), "").unwrap();
     let path = dir.with_filename("file");
 
     {
index 9f23ab1c9dfa68e0c3f27721cd100d5d652d2404..b426212d872f25a8605f254781a3a8bcc583dd49 100644 (file)
@@ -29,7 +29,7 @@ fn test00() {
     }
 
     // Try joining tasks that have already finished.
-    option::unwrap(result).recv();
+    result.unwrap().recv();
 
     debug!("Joined task.");
 }
index 57e07221c3df5da1bc28cc7acf6227187839ebb7..767203a1f630dcc775c0155a2d10702b8c6fab93 100644 (file)
@@ -39,7 +39,7 @@ fn test00() {
         i += 1;
     }
 
-    option::unwrap(result).recv();
+    result.unwrap().recv();
 
     fail_unless!((sum == number_of_messages * (number_of_messages - 1) / 2));
 }
index 16f43016b8e673b0220b166459c9c2190d028e9e..75d9979807b47afe9cb54dcb8f91afa3cf791813 100644 (file)
@@ -17,7 +17,7 @@ pub fn main() {
     error!("2");
     task::yield();
     error!("3");
-    option::unwrap(result).recv();
+    result.unwrap().recv();
 }
 
 fn child() {
index ae1271f64e4dc3d84ba5fc621a5e28032e1eeed9..51483121f50fc0368c16754bc69d5e8bf7c82acd 100644 (file)
@@ -14,7 +14,7 @@ pub fn main() {
     task::task().future_result(|+r| { result = Some(r); }).spawn(child);
     error!("1");
     task::yield();
-    option::unwrap(result).recv();
+    result.unwrap().recv();
 }
 
 fn child() { error!("2"); }