about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/at_vec.rs6
-rw-r--r--src/libstd/either.rs366
-rw-r--r--src/libstd/local_data.rs14
-rw-r--r--src/libstd/num/strconv.rs2
-rw-r--r--src/libstd/option.rs212
-rw-r--r--src/libstd/os.rs6
-rw-r--r--src/libstd/rand.rs4
-rw-r--r--src/libstd/result.rs327
-rw-r--r--src/libstd/rt/io/flate.rs2
-rw-r--r--src/libstd/rt/io/mod.rs36
-rw-r--r--src/libstd/rt/mod.rs2
-rw-r--r--src/libstd/rt/task.rs4
-rw-r--r--src/libstd/rt/test.rs4
-rw-r--r--src/libstd/rt/util.rs4
-rw-r--r--src/libstd/rt/uv/net.rs6
-rw-r--r--src/libstd/rt/uv/uvio.rs2
-rw-r--r--src/libstd/str.rs4
-rw-r--r--src/libstd/task/mod.rs2
-rw-r--r--src/libstd/vec.rs6
19 files changed, 493 insertions, 516 deletions
diff --git a/src/libstd/at_vec.rs b/src/libstd/at_vec.rs
index 4ece53d0e7f..a84f3137bbd 100644
--- a/src/libstd/at_vec.rs
+++ b/src/libstd/at_vec.rs
@@ -78,10 +78,8 @@ pub fn build<A>(builder: &fn(push: &fn(v: A))) -> @[A] {
  *             onto the vector being constructed.
  */
 #[inline]
-pub fn build_sized_opt<A>(size: Option<uint>,
-                          builder: &fn(push: &fn(v: A)))
-                       -> @[A] {
-    build_sized(size.get_or_default(4), builder)
+pub fn build_sized_opt<A>(size: Option<uint>, builder: &fn(push: &fn(v: A))) -> @[A] {
+    build_sized(size.unwrap_or_default(4), builder)
 }
 
 // Appending
diff --git a/src/libstd/either.rs b/src/libstd/either.rs
index 6bdc45d7204..cfaef550c6f 100644
--- a/src/libstd/either.rs
+++ b/src/libstd/either.rs
@@ -23,29 +23,102 @@ use str::StrSlice;
 use vec;
 use vec::{OwnedVector, ImmutableVector};
 
-/// The either type
+/// `Either` is a type that represents one of two alternatives
 #[deriving(Clone, Eq)]
-pub enum Either<T, U> {
-    Left(T),
-    Right(U)
+pub enum Either<L, R> {
+    Left(L),
+    Right(R)
 }
 
-/// Applies a function based on the given either value
-///
-/// If `value` is left(T) then `f_left` is applied to its contents, if
-/// `value` is right(U) then `f_right` is applied to its contents, and the
-/// result is returned.
-#[inline]
-pub fn either<T, U, V>(f_left: &fn(&T) -> V,
-                       f_right: &fn(&U) -> V, value: &Either<T, U>) -> V {
-    match *value {
-        Left(ref l) => f_left(l),
-        Right(ref r) => f_right(r)
+impl<L, R> Either<L, R> {
+    /// Applies a function based on the given either value
+    ///
+    /// If `value` is `Left(L)` then `f_left` is applied to its contents, if
+    /// `value` is `Right(R)` then `f_right` is applied to its contents, and the
+    /// result is returned.
+    #[inline]
+    pub fn either<T>(&self, f_left: &fn(&L) -> T, f_right: &fn(&R) -> T) -> T {
+        match *self {
+            Left(ref l) => f_left(l),
+            Right(ref r) => f_right(r)
+        }
+    }
+
+    /// Flips between left and right of a given `Either`
+    #[inline]
+    pub fn flip(self) -> Either<R, L> {
+        match self {
+            Right(r) => Left(r),
+            Left(l) => Right(l)
+        }
+    }
+
+    /// Converts a `Either` to a `Result`
+    ///
+    /// Converts an `Either` type to a `Result` type, making the "right" choice
+    /// an `Ok` result, and the "left" choice a `Err`
+    #[inline]
+    pub fn to_result(self) -> Result<R, L> {
+        match self {
+            Right(r) => result::Ok(r),
+            Left(l) => result::Err(l)
+        }
+    }
+
+    /// Checks whether the given value is a `Left`
+    #[inline]
+    pub fn is_left(&self) -> bool {
+        match *self {
+            Left(_) => true,
+            _ => false
+        }
+    }
+
+    /// Checks whether the given value is a `Right`
+    #[inline]
+    pub fn is_right(&self) -> bool {
+        match *self {
+            Right(_) => true,
+            _ => false
+        }
+    }
+
+    /// Retrieves the value from a `Left`.
+    /// Fails with a specified reason if the `Either` is `Right`.
+    #[inline]
+    pub fn expect_left(self, reason: &str) -> L {
+        match self {
+            Left(x) => x,
+            Right(_) => fail!(reason.to_owned())
+        }
+    }
+
+    /// Retrieves the value from a `Left`. Fails if the `Either` is `Right`.
+    #[inline]
+    pub fn unwrap_left(self) -> L {
+        self.expect_left("called Either::unwrap_left()` on `Right` value")
+    }
+
+    /// Retrieves the value from a `Right`.
+    /// Fails with a specified reason if the `Either` is `Left`.
+    #[inline]
+    pub fn expect_right(self, reason: &str) -> R {
+        match self {
+            Right(x) => x,
+            Left(_) => fail!(reason.to_owned())
+        }
+    }
+
+    /// Retrieves the value from a `Right`. Fails if the `Either` is `Left`.
+    #[inline]
+    pub fn unwrap_right(self) -> R {
+        self.expect_right("called Either::unwrap_right()` on `Left` value")
     }
 }
 
+// FIXME: #8228 Replaceable by an external iterator?
 /// Extracts from a vector of either all the left values
-pub fn lefts<T:Clone,U>(eithers: &[Either<T, U>]) -> ~[T] {
+pub fn lefts<L: Clone, R>(eithers: &[Either<L, R>]) -> ~[L] {
     do vec::build_sized(eithers.len()) |push| {
         for elt in eithers.iter() {
             match *elt {
@@ -56,8 +129,9 @@ pub fn lefts<T:Clone,U>(eithers: &[Either<T, U>]) -> ~[T] {
     }
 }
 
+// FIXME: #8228 Replaceable by an external iterator?
 /// Extracts from a vector of either all the right values
-pub fn rights<T, U: Clone>(eithers: &[Either<T, U>]) -> ~[U] {
+pub fn rights<L, R: Clone>(eithers: &[Either<L, R>]) -> ~[R] {
     do vec::build_sized(eithers.len()) |push| {
         for elt in eithers.iter() {
             match *elt {
@@ -68,13 +142,14 @@ pub fn rights<T, U: Clone>(eithers: &[Either<T, U>]) -> ~[U] {
     }
 }
 
+// FIXME: #8228 Replaceable by an external iterator?
 /// Extracts from a vector of either all the left values and right values
 ///
 /// Returns a structure containing a vector of left values and a vector of
 /// right values.
-pub fn partition<T, U>(eithers: ~[Either<T, U>]) -> (~[T], ~[U]) {
-    let mut lefts: ~[T] = ~[];
-    let mut rights: ~[U] = ~[];
+pub fn partition<L, R>(eithers: ~[Either<L, R>]) -> (~[L], ~[R]) {
+    let mut lefts: ~[L] = ~[];
+    let mut rights: ~[R] = ~[];
     for elt in eithers.consume_iter() {
         match elt {
             Left(l) => lefts.push(l),
@@ -84,196 +159,101 @@ pub fn partition<T, U>(eithers: ~[Either<T, U>]) -> (~[T], ~[U]) {
     return (lefts, rights);
 }
 
-/// Flips between left and right of a given either
-#[inline]
-pub fn flip<T, U>(eith: Either<T, U>) -> Either<U, T> {
-    match eith {
-        Right(r) => Left(r),
-        Left(l) => Right(l)
-    }
-}
+#[cfg(test)]
+mod tests {
+    use super::*;
 
-/// Converts either::t to a result::t
-///
-/// Converts an `either` type to a `result` type, making the "right" choice
-/// an ok result, and the "left" choice a fail
-#[inline]
-pub fn to_result<T, U>(eith: Either<T, U>) -> Result<U, T> {
-    match eith {
-        Right(r) => result::Ok(r),
-        Left(l) => result::Err(l)
+    #[test]
+    fn test_either_left() {
+        let val = Left(10);
+        fn f_left(x: &int) -> bool { *x == 10 }
+        fn f_right(_x: &uint) -> bool { false }
+        assert!(val.either(f_left, f_right));
     }
-}
 
-/// Checks whether the given value is a left
-#[inline]
-pub fn is_left<T, U>(eith: &Either<T, U>) -> bool {
-    match *eith {
-        Left(_) => true,
-        _ => false
+    #[test]
+    fn test_either_right() {
+        let val = Right(10u);
+        fn f_left(_x: &int) -> bool { false }
+        fn f_right(x: &uint) -> bool { *x == 10u }
+        assert!(val.either(f_left, f_right));
     }
-}
 
-/// Checks whether the given value is a right
-#[inline]
-pub fn is_right<T, U>(eith: &Either<T, U>) -> bool {
-    match *eith {
-        Right(_) => true,
-        _ => false
+    #[test]
+    fn test_lefts() {
+        let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)];
+        let result = lefts(input);
+        assert_eq!(result, ~[10, 12, 14]);
     }
-}
 
-/// Retrieves the value in the left branch.
-/// Fails with a specified reason if the either is Right.
-#[inline]
-pub fn expect_left<T,U>(eith: Either<T,U>, reason: &str) -> T {
-    match eith {
-        Left(x) => x,
-        Right(_) => fail!(reason.to_owned())
+    #[test]
+    fn test_lefts_none() {
+        let input: ~[Either<int, int>] = ~[Right(10), Right(10)];
+        let result = lefts(input);
+        assert_eq!(result.len(), 0u);
     }
-}
 
-/// Retrieves the value in the left branch. Fails if the either is Right.
-#[inline]
-pub fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
-    expect_left(eith, "either::unwrap_left Right")
-}
-
-/// Retrieves the value in the right branch.
-/// Fails with a specified reason if the either is Left.
-#[inline]
-pub fn expect_right<T,U>(eith: Either<T,U>, reason: &str) -> U {
-    match eith {
-        Right(x) => x,
-        Left(_) => fail!(reason.to_owned())
+    #[test]
+    fn test_lefts_empty() {
+        let input: ~[Either<int, int>] = ~[];
+        let result = lefts(input);
+        assert_eq!(result.len(), 0u);
     }
-}
 
-/// Retrieves the value in the right branch. Fails if the either is Left.
-pub fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
-    expect_right(eith, "either::unwrap_right Left")
-}
-
-impl<T, U> Either<T, U> {
-    #[inline]
-    pub fn either<V>(&self, f_left: &fn(&T) -> V, f_right: &fn(&U) -> V) -> V {
-        either(f_left, f_right, self)
+    #[test]
+    fn test_rights() {
+        let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)];
+        let result = rights(input);
+        assert_eq!(result, ~[11, 13]);
     }
 
-    #[inline]
-    pub fn flip(self) -> Either<U, T> { flip(self) }
-
-    #[inline]
-    pub fn to_result(self) -> Result<U, T> { to_result(self) }
-
-    #[inline]
-    pub fn is_left(&self) -> bool { is_left(self) }
-
-    #[inline]
-    pub fn is_right(&self) -> bool { is_right(self) }
-
-    #[inline]
-    pub fn expect_left(self, reason: &str) -> T { expect_left(self, reason) }
-
-    #[inline]
-    pub fn unwrap_left(self) -> T { unwrap_left(self) }
-
-    #[inline]
-    pub fn expect_right(self, reason: &str) -> U { expect_right(self, reason) }
-
-    #[inline]
-    pub fn unwrap_right(self) -> U { unwrap_right(self) }
-}
-
-#[test]
-fn test_either_left() {
-    let val = Left(10);
-    fn f_left(x: &int) -> bool { *x == 10 }
-    fn f_right(_x: &uint) -> bool { false }
-    assert!((either(f_left, f_right, &val)));
-}
-
-#[test]
-fn test_either_right() {
-    let val = Right(10u);
-    fn f_left(_x: &int) -> bool { false }
-    fn f_right(x: &uint) -> bool { *x == 10u }
-    assert!((either(f_left, f_right, &val)));
-}
-
-#[test]
-fn test_lefts() {
-    let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)];
-    let result = lefts(input);
-    assert_eq!(result, ~[10, 12, 14]);
-}
-
-#[test]
-fn test_lefts_none() {
-    let input: ~[Either<int, int>] = ~[Right(10), Right(10)];
-    let result = lefts(input);
-    assert_eq!(result.len(), 0u);
-}
-
-#[test]
-fn test_lefts_empty() {
-    let input: ~[Either<int, int>] = ~[];
-    let result = lefts(input);
-    assert_eq!(result.len(), 0u);
-}
-
-#[test]
-fn test_rights() {
-    let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)];
-    let result = rights(input);
-    assert_eq!(result, ~[11, 13]);
-}
+    #[test]
+    fn test_rights_none() {
+        let input: ~[Either<int, int>] = ~[Left(10), Left(10)];
+        let result = rights(input);
+        assert_eq!(result.len(), 0u);
+    }
 
-#[test]
-fn test_rights_none() {
-    let input: ~[Either<int, int>] = ~[Left(10), Left(10)];
-    let result = rights(input);
-    assert_eq!(result.len(), 0u);
-}
+    #[test]
+    fn test_rights_empty() {
+        let input: ~[Either<int, int>] = ~[];
+        let result = rights(input);
+        assert_eq!(result.len(), 0u);
+    }
 
-#[test]
-fn test_rights_empty() {
-    let input: ~[Either<int, int>] = ~[];
-    let result = rights(input);
-    assert_eq!(result.len(), 0u);
-}
+    #[test]
+    fn test_partition() {
+        let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)];
+        let (lefts, rights) = partition(input);
+        assert_eq!(lefts[0], 10);
+        assert_eq!(lefts[1], 12);
+        assert_eq!(lefts[2], 14);
+        assert_eq!(rights[0], 11);
+        assert_eq!(rights[1], 13);
+    }
 
-#[test]
-fn test_partition() {
-    let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)];
-    let (lefts, rights) = partition(input);
-    assert_eq!(lefts[0], 10);
-    assert_eq!(lefts[1], 12);
-    assert_eq!(lefts[2], 14);
-    assert_eq!(rights[0], 11);
-    assert_eq!(rights[1], 13);
-}
+    #[test]
+    fn test_partition_no_lefts() {
+        let input: ~[Either<int, int>] = ~[Right(10), Right(11)];
+        let (lefts, rights) = partition(input);
+        assert_eq!(lefts.len(), 0u);
+        assert_eq!(rights.len(), 2u);
+    }
 
-#[test]
-fn test_partition_no_lefts() {
-    let input: ~[Either<int, int>] = ~[Right(10), Right(11)];
-    let (lefts, rights) = partition(input);
-    assert_eq!(lefts.len(), 0u);
-    assert_eq!(rights.len(), 2u);
-}
+    #[test]
+    fn test_partition_no_rights() {
+        let input: ~[Either<int, int>] = ~[Left(10), Left(11)];
+        let (lefts, rights) = partition(input);
+        assert_eq!(lefts.len(), 2u);
+        assert_eq!(rights.len(), 0u);
+    }
 
-#[test]
-fn test_partition_no_rights() {
-    let input: ~[Either<int, int>] = ~[Left(10), Left(11)];
-    let (lefts, rights) = partition(input);
-    assert_eq!(lefts.len(), 2u);
-    assert_eq!(rights.len(), 0u);
-}
+    #[test]
+    fn test_partition_empty() {
+        let input: ~[Either<int, int>] = ~[];
+        let (lefts, rights) = partition(input);
+        assert_eq!(lefts.len(), 0u);
+        assert_eq!(rights.len(), 0u);
+    }
 
-#[test]
-fn test_partition_empty() {
-    let input: ~[Either<int, int>] = ~[];
-    let (lefts, rights) = partition(input);
-    assert_eq!(lefts.len(), 0u);
-    assert_eq!(rights.len(), 0u);
 }
diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs
index 537289c8dd6..c2a60e1c0e9 100644
--- a/src/libstd/local_data.rs
+++ b/src/libstd/local_data.rs
@@ -112,14 +112,14 @@ fn test_tls_multitask() {
         // TLS shouldn't carry over.
         assert!(get(my_key, |k| k.map(|&k| *k)).is_none());
         set(my_key, @~"child data");
-        assert!(*(get(my_key, |k| k.map(|&k| *k)).get()) ==
+        assert!(*(get(my_key, |k| k.map(|&k| *k)).unwrap()) ==
                 ~"child data");
         // should be cleaned up for us
     }
     // Must work multiple times
-    assert!(*(get(my_key, |k| k.map(|&k| *k)).get()) == ~"parent data");
-    assert!(*(get(my_key, |k| k.map(|&k| *k)).get()) == ~"parent data");
-    assert!(*(get(my_key, |k| k.map(|&k| *k)).get()) == ~"parent data");
+    assert!(*(get(my_key, |k| k.map(|&k| *k)).unwrap()) == ~"parent data");
+    assert!(*(get(my_key, |k| k.map(|&k| *k)).unwrap()) == ~"parent data");
+    assert!(*(get(my_key, |k| k.map(|&k| *k)).unwrap()) == ~"parent data");
 }
 
 #[test]
@@ -127,14 +127,14 @@ fn test_tls_overwrite() {
     static my_key: Key<@~str> = &Key;
     set(my_key, @~"first data");
     set(my_key, @~"next data"); // Shouldn't leak.
-    assert!(*(get(my_key, |k| k.map(|&k| *k)).get()) == ~"next data");
+    assert!(*(get(my_key, |k| k.map(|&k| *k)).unwrap()) == ~"next data");
 }
 
 #[test]
 fn test_tls_pop() {
     static my_key: Key<@~str> = &Key;
     set(my_key, @~"weasel");
-    assert!(*(pop(my_key).get()) == ~"weasel");
+    assert!(*(pop(my_key).unwrap()) == ~"weasel");
     // Pop must remove the data from the map.
     assert!(pop(my_key).is_none());
 }
@@ -155,7 +155,7 @@ fn test_tls_modify() {
             None                 => fail!("missing value")
         }
     });
-    assert!(*(pop(my_key).get()) == ~"next data");
+    assert!(*(pop(my_key).unwrap()) == ~"next data");
 }
 
 #[test]
diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs
index 722af828d5c..7ab3c81b61f 100644
--- a/src/libstd/num/strconv.rs
+++ b/src/libstd/num/strconv.rs
@@ -726,4 +726,4 @@ mod bench {
             float::to_str(rng.gen());
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/libstd/option.rs b/src/libstd/option.rs
index 417251d3740..3a4a9220ee1 100644
--- a/src/libstd/option.rs
+++ b/src/libstd/option.rs
@@ -47,7 +47,8 @@ use ops::Add;
 use util;
 use num::Zero;
 use iterator::Iterator;
-use str::StrSlice;
+use str::{StrSlice, OwnedStr};
+use to_str::ToStr;
 use clone::DeepClone;
 
 /// The option type
@@ -85,18 +86,33 @@ impl<T:Ord> Ord for Option<T> {
     }
 }
 
-impl<T:Clone+Add<T,T>> Add<Option<T>, Option<T>> for Option<T> {
+impl<T: Add<T, T>> Add<Option<T>, Option<T>> for Option<T> {
     #[inline]
     fn add(&self, other: &Option<T>) -> Option<T> {
         match (&*self, &*other) {
             (&None, &None) => None,
-            (_, &None) => (*self).clone(),
-            (&None, _) => (*other).clone(),
+            (_, &None) => None,
+            (&None, _) => None,
             (&Some(ref lhs), &Some(ref rhs)) => Some(*lhs + *rhs)
         }
     }
 }
 
+// FIXME: #8242 implementing manually because deriving doesn't work for some reason
+impl<T: ToStr> ToStr for Option<T> {
+    fn to_str(&self) -> ~str {
+        match *self {
+            Some(ref x) => {
+                let mut s = ~"Some(";
+                s.push_str(x.to_str());
+                s.push_str(")");
+                s
+            }
+            None => ~"None"
+        }
+    }
+}
+
 impl<T> Option<T> {
     /// Return an iterator over the possibly contained value
     #[inline]
@@ -148,8 +164,7 @@ impl<T> Option<T> {
     /// Update an optional value by optionally running its content by reference
     /// through a function that returns an option.
     #[inline]
-    pub fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option<U>)
-                            -> Option<U> {
+    pub fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option<U>) -> Option<U> {
         match *self {
             Some(ref x) => f(x),
             None => None
@@ -159,8 +174,7 @@ impl<T> Option<T> {
     /// Update an optional value by optionally running its content by mut reference
     /// through a function that returns an option.
     #[inline]
-    pub fn chain_mut_ref<'a, U>(&'a mut self, f: &fn(x: &'a mut T) -> Option<U>)
-                                -> Option<U> {
+    pub fn chain_mut_ref<'a, U>(&'a mut self, f: &fn(x: &'a mut T) -> Option<U>) -> Option<U> {
         match *self {
             Some(ref mut x) => f(x),
             None => None
@@ -256,132 +270,105 @@ impl<T> Option<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.
-     */
+    /// 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.
     #[inline]
     pub fn get_ref<'a>(&'a self) -> &'a T {
         match *self {
-          Some(ref x) => x,
-          None => fail!("option::get_ref `None`"),
+            Some(ref x) => x,
+            None => fail!("called `Option::get_ref()` on a `None` value"),
         }
     }
 
-    /**
-    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.
-     */
+    /// 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.
     #[inline]
     pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T {
         match *self {
-          Some(ref mut x) => x,
-          None => fail!("option::get_mut_ref `None`"),
+            Some(ref mut x) => x,
+            None => fail!("called `Option::get_mut_ref()` on a `None` value"),
         }
     }
 
+    /// 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.
     #[inline]
     pub 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`"),
+            Some(x) => x,
+            None => fail!("called `Option::unwrap()` on a `None` value"),
         }
     }
 
-    /**
-     * 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`.
-     */
+    /// 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`.
     #[inline]
     pub fn take_unwrap(&mut self) -> T {
-        if self.is_none() { fail!("option::take_unwrap `None`") }
+        if self.is_none() {
+            fail!("called `Option::take_unwrap()` on a `None` value")
+        }
         self.take().unwrap()
     }
 
-    /**
-     * Gets the value out of an option, printing a specified message on
-     * failure
-     *
-     * # Failure
-     *
-     * Fails if the value equals `None`
-     */
+    ///  Gets the value out of an option, printing a specified message on
+    ///  failure
+    ///
+    ///  # Failure
+    ///
+    ///  Fails if the value equals `None`
     #[inline]
     pub fn expect(self, reason: &str) -> T {
         match self {
-          Some(val) => val,
-          None => fail!(reason.to_owned()),
+            Some(val) => val,
+            None => fail!(reason.to_owned()),
         }
     }
 
-    /**
-    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.
-    */
+    /// Returns the contained value or a default
     #[inline]
-    pub fn get(self) -> T {
+    pub fn unwrap_or_default(self, def: T) -> T {
         match self {
-          Some(x) => return x,
-          None => fail!("option::get `None`")
+            Some(x) => x,
+            None => def
         }
     }
 
-    /// Returns the contained value or a default
-    #[inline]
-    pub fn get_or_default(self, def: T) -> T {
-        match self { Some(x) => x, None => def }
-    }
-
     /// Applies a function zero or more times until the result is `None`.
     #[inline]
     pub fn while_some(self, blk: &fn(v: T) -> Option<T>) {
@@ -395,12 +382,21 @@ impl<T> Option<T> {
 impl<T:Zero> Option<T> {
     /// Returns the contained value or zero (for this type)
     #[inline]
-    pub fn get_or_zero(self) -> T {
+    pub fn unwrap_or_zero(self) -> T {
         match self {
             Some(x) => x,
             None => Zero::zero()
         }
     }
+
+    /// Returns self or `Some(zero)` (for this type)
+    #[inline]
+    pub fn or_zero(self) -> Option<T> {
+        match self {
+            None => Some(Zero::zero()),
+            x => x
+        }
+    }
 }
 
 impl<T> Zero for Option<T> {
@@ -450,7 +446,7 @@ mod tests {
     use util;
 
     #[test]
-    fn test_unwrap_ptr() {
+    fn test_get_ptr() {
         unsafe {
             let x = ~0;
             let addr_x: *int = ::cast::transmute(&*x);
@@ -462,7 +458,7 @@ mod tests {
     }
 
     #[test]
-    fn test_unwrap_str() {
+    fn test_get_str() {
         let x = ~"test";
         let addr_x = x.as_imm_buf(|buf, _len| buf);
         let opt = Some(x);
@@ -472,7 +468,7 @@ mod tests {
     }
 
     #[test]
-    fn test_unwrap_resource() {
+    fn test_get_resource() {
         struct R {
            i: @mut int,
         }
@@ -530,18 +526,18 @@ mod tests {
     }
 
     #[test]
-    fn test_get_or_zero() {
+    fn test_unwrap_or_zero() {
         let some_stuff = Some(42);
-        assert_eq!(some_stuff.get_or_zero(), 42);
+        assert_eq!(some_stuff.unwrap_or_zero(), 42);
         let no_stuff: Option<int> = None;
-        assert_eq!(no_stuff.get_or_zero(), 0);
+        assert_eq!(no_stuff.unwrap_or_zero(), 0);
     }
 
     #[test]
     fn test_filtered() {
         let some_stuff = Some(42);
         let modified_stuff = some_stuff.filtered(|&x| {x < 10});
-        assert_eq!(some_stuff.get(), 42);
+        assert_eq!(some_stuff.unwrap(), 42);
         assert!(modified_stuff.is_none());
     }
 
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 2d0b7d4f849..b0e1f35b4a0 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -571,7 +571,7 @@ pub fn tmpdir() -> Path {
 
     #[cfg(unix)]
     fn lookup() -> Path {
-        getenv_nonempty("TMPDIR").get_or_default(Path("/tmp"))
+        getenv_nonempty("TMPDIR").unwrap_or_default(Path("/tmp"))
     }
 
     #[cfg(windows)]
@@ -579,7 +579,7 @@ pub fn tmpdir() -> Path {
         getenv_nonempty("TMP").or(
             getenv_nonempty("TEMP").or(
                 getenv_nonempty("USERPROFILE").or(
-                   getenv_nonempty("WINDIR")))).get_or_default(Path("C:\\Windows"))
+                   getenv_nonempty("WINDIR")))).unwrap_or_default(Path("C:\\Windows"))
     }
 }
 
@@ -1782,7 +1782,7 @@ mod tests {
     fn test_self_exe_path() {
         let path = os::self_exe_path();
         assert!(path.is_some());
-        let path = path.get();
+        let path = path.unwrap();
         debug!(path.clone());
 
         // Hard to test this function
diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs
index b7d72c11ff7..4ef524d7715 100644
--- a/src/libstd/rand.rs
+++ b/src/libstd/rand.rs
@@ -533,7 +533,7 @@ impl<R: Rng> RngUtil for R {
 
     /// Choose an item randomly, failing if values is empty
     fn choose<T:Clone>(&mut self, values: &[T]) -> T {
-        self.choose_option(values).get()
+        self.choose_option(values).unwrap()
     }
 
     /// Choose Some(item) randomly, returning None if values is empty
@@ -549,7 +549,7 @@ impl<R: Rng> RngUtil for R {
      * the weights is 0
      */
     fn choose_weighted<T:Clone>(&mut self, v: &[Weighted<T>]) -> T {
-        self.choose_weighted_option(v).get()
+        self.choose_weighted_option(v).unwrap()
     }
 
     /**
diff --git a/src/libstd/result.rs b/src/libstd/result.rs
index 7a578465841..181590e3929 100644
--- a/src/libstd/result.rs
+++ b/src/libstd/result.rs
@@ -20,23 +20,27 @@ use option::{None, Option, Some};
 use vec;
 use vec::{OwnedVector, ImmutableVector};
 use container::Container;
-
-/// The result type
+use to_str::ToStr;
+use str::StrSlice;
+
+/// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
+///
+/// In order to provide informative error messages, `E` is reqired to implement `ToStr`.
+/// It is further recommended for `E` to be a descriptive error type, eg a `enum` for
+/// all possible errors cases.
 #[deriving(Clone, Eq)]
-pub enum Result<T, U> {
+pub enum Result<T, E> {
     /// Contains the successful result value
     Ok(T),
     /// Contains the error value
-    Err(U)
+    Err(E)
 }
 
-impl<T, E> Result<T, E> {
-    /**
-     * Convert to the `either` type
-     *
-     * `Ok` result variants are converted to `either::Right` variants, `Err`
-     * result variants are converted to `either::Left`.
-     */
+impl<T, E: ToStr> Result<T, E> {
+    /// Convert to the `either` type
+    ///
+    /// `Ok` result variants are converted to `either::Right` variants, `Err`
+    /// result variants are converted to `either::Left`.
     #[inline]
     pub fn to_either(self)-> either::Either<E, T>{
         match self {
@@ -45,18 +49,16 @@ impl<T, E> Result<T, E> {
         }
     }
 
-    /**
-     * Get a reference to the value out of a successful result
-     *
-     * # Failure
-     *
-     * If the result is an error
-     */
+    /// Get a reference to the value out of a successful result
+    ///
+    /// # Failure
+    ///
+    /// If the result is an error
     #[inline]
     pub fn get_ref<'a>(&'a self) -> &'a T {
         match *self {
             Ok(ref t) => t,
-            Err(ref e) => fail!("get_ref called on `Err` result: %?", *e),
+            Err(ref e) => fail!("called `Result::get_ref()` on `Err` value: %s", e.to_str()),
         }
     }
 
@@ -75,20 +77,18 @@ impl<T, E> Result<T, E> {
         !self.is_ok()
     }
 
-    /**
-     * Call a method based on a previous result
-     *
-     * If `self` is `Ok` then the value is extracted and passed to `op`
-     * whereupon `op`s result is returned. if `self` is `Err` then it is
-     * immediately returned. This function can be used to compose the results
-     * of two functions.
-     *
-     * Example:
-     *
-     *     do read_file(file).iter |buf| {
-     *         print_buf(buf)
-     *     }
-     */
+    /// Call a method based on a previous result
+    ///
+    /// If `self` is `Ok` then the value is extracted and passed to `op`
+    /// whereupon `op`s result is returned. if `self` is `Err` then it is
+    /// immediately returned. This function can be used to compose the results
+    /// of two functions.
+    ///
+    /// Example:
+    ///
+    ///     do read_file(file).iter |buf| {
+    ///         print_buf(buf)
+    ///     }
     #[inline]
     pub fn iter(&self, f: &fn(&T)) {
         match *self {
@@ -97,14 +97,12 @@ impl<T, E> Result<T, E> {
         }
     }
 
-    /**
-     * Call a method based on a previous result
-     *
-     * If `self` is `Err` then the value is extracted and passed to `op`
-     * whereupon `op`s result is returned. if `self` is `Ok` then it is
-     * immediately returned.  This function can be used to pass through a
-     * successful result while handling an error.
-     */
+    /// Call a method based on a previous result
+    ///
+    /// If `self` is `Err` then the value is extracted and passed to `op`
+    /// whereupon `op`s result is returned. if `self` is `Ok` then it is
+    /// immediately returned.  This function can be used to pass through a
+    /// successful result while handling an error.
     #[inline]
     pub fn iter_err(&self, f: &fn(&E)) {
         match *self {
@@ -113,38 +111,56 @@ impl<T, E> Result<T, E> {
         }
     }
 
-    /// Unwraps a result, assuming it is an `Ok(T)`
+    /// Unwraps a result, yielding the content of an `Ok`.
+    /// Fails if the value is a `Err` with an error message derived
+    /// from `E`'s `ToStr` implementation.
     #[inline]
     pub fn unwrap(self) -> T {
         match self {
             Ok(t) => t,
-            Err(_) => fail!("unwrap called on an `Err` result"),
+            Err(e) => fail!("called `Result::unwrap()` on `Err` value: %s", e.to_str()),
         }
     }
 
-    /// Unwraps a result, assuming it is an `Err(U)`
+    /// Unwraps a result, yielding the content of an `Err`.
+    /// Fails if the value is a `Ok`.
     #[inline]
     pub fn unwrap_err(self) -> E {
+        self.expect_err("called `Result::unwrap_err()` on `Ok` value")
+    }
+
+    /// Unwraps a result, yielding the content of an `Ok`.
+    /// Fails if the value is a `Err` with a custom failure message.
+    #[inline]
+    pub fn expect(self, reason: &str) -> T {
+        match self {
+            Ok(t) => t,
+            Err(_) => fail!(reason.to_owned()),
+        }
+    }
+
+    /// Unwraps a result, yielding the content of an `Err`
+    /// Fails if the value is a `Ok` with a custom failure message.
+    #[inline]
+    pub fn expect_err(self, reason: &str) -> E {
         match self {
             Err(e) => e,
-            Ok(_) => fail!("unwrap called on an `Ok` result"),
+            Ok(_) => fail!(reason.to_owned()),
         }
     }
 
-    /**
-     * Call a method based on a previous result
-     *
-     * If `self` is `Ok` then the value is extracted and passed to `op`
-     * whereupon `op`s result is returned. if `self` is `Err` then it is
-     * immediately returned. This function can be used to compose the results
-     * of two functions.
-     *
-     * Example:
-     *
-     *     let res = do read_file(file) |buf| {
-     *         Ok(parse_bytes(buf))
-     *     };
-     */
+    /// Call a method based on a previous result
+    ///
+    /// If `self` is `Ok` then the value is extracted and passed to `op`
+    /// whereupon `op`s result is returned. if `self` is `Err` then it is
+    /// immediately returned. This function can be used to compose the results
+    /// of two functions.
+    ///
+    /// Example:
+    ///
+    ///     let res = do read_file(file) |buf| {
+    ///         Ok(parse_bytes(buf))
+    ///     };
     #[inline]
     pub fn chain<U>(self, op: &fn(T) -> Result<U, E>) -> Result<U, E> {
         match self {
@@ -153,14 +169,12 @@ impl<T, E> Result<T, E> {
         }
     }
 
-    /**
-     * Call a function based on a previous result
-     *
-     * If `self` is `Err` then the value is extracted and passed to `op`
-     * whereupon `op`s result is returned. if `self` is `Ok` then it is
-     * immediately returned.  This function can be used to pass through a
-     * successful result while handling an error.
-     */
+    /// Call a function based on a previous result
+    ///
+    /// If `self` is `Err` then the value is extracted and passed to `op`
+    /// whereupon `op`s result is returned. if `self` is `Ok` then it is
+    /// immediately returned.  This function can be used to pass through a
+    /// successful result while handling an error.
     #[inline]
     pub fn chain_err<F>(self, op: &fn(E) -> Result<T, F>) -> Result<T, F> {
         match self {
@@ -170,32 +184,15 @@ impl<T, E> Result<T, E> {
     }
 }
 
-impl<T: Clone, E> Result<T, E> {
-    /**
-     * Get the value out of a successful result
-     *
-     * # Failure
-     *
-     * If the result is an error
-     */
+impl<T: Clone, E: ToStr> Result<T, E> {
+    /// Call a method based on a previous result
+    ///
+    /// If `self` is `Err` then the value is extracted and passed to `op`
+    /// whereupon `op`s result is wrapped in an `Err` and returned. if `self` is
+    /// `Ok` then it is immediately returned.  This function can be used to pass
+    /// through a successful result while handling an error.
     #[inline]
-    pub fn get(&self) -> T {
-        match *self {
-            Ok(ref t) => t.clone(),
-            Err(ref e) => fail!("get called on `Err` result: %?", *e),
-        }
-    }
-
-    /**
-     * Call a method based on a previous result
-     *
-     * If `self` is `Err` then the value is extracted and passed to `op`
-     * whereupon `op`s result is wrapped in an `Err` and returned. if `self` is
-     * `Ok` then it is immediately returned.  This function can be used to pass
-     * through a successful result while handling an error.
-     */
-    #[inline]
-    pub fn map_err<F:Clone>(&self, op: &fn(&E) -> F) -> Result<T,F> {
+    pub fn map_err<F: Clone>(&self, op: &fn(&E) -> F) -> Result<T,F> {
         match *self {
             Ok(ref t) => Ok(t.clone()),
             Err(ref e) => Err(op(e))
@@ -203,62 +200,57 @@ impl<T: Clone, E> Result<T, E> {
     }
 }
 
-impl<T, E: Clone> Result<T, E> {
-    /**
-     * Get the value out of an error result
-     *
-     * # Failure
-     *
-     * If the result is not an error
-     */
+impl<T, E: Clone + ToStr> Result<T, E> {
+    /// Call a method based on a previous result
+    ///
+    /// If `self` is `Ok` then the value is extracted and passed to `op`
+    /// whereupon `op`s result is wrapped in `Ok` and returned. if `self` is
+    /// `Err` then it is immediately returned.  This function can be used to
+    /// compose the results of two functions.
+    ///
+    /// Example:
+    ///
+    ///     let res = do read_file(file).map |buf| {
+    ///         parse_bytes(buf)
+    ///     };
     #[inline]
-    pub fn get_err(&self) -> E {
+    pub fn map<U: Clone>(&self, op: &fn(&T) -> U) -> Result<U,E> {
         match *self {
-            Err(ref e) => e.clone(),
-            Ok(_) => fail!("get_err called on `Ok` result")
+            Ok(ref t) => Ok(op(t)),
+            Err(ref e) => Err(e.clone())
         }
     }
+}
 
-    /**
-     * Call a method based on a previous result
-     *
-     * If `self` is `Ok` then the value is extracted and passed to `op`
-     * whereupon `op`s result is wrapped in `Ok` and returned. if `self` is
-     * `Err` then it is immediately returned.  This function can be used to
-     * compose the results of two functions.
-     *
-     * Example:
-     *
-     *     let res = do read_file(file).map |buf| {
-     *         parse_bytes(buf)
-     *     };
-     */
-    #[inline]
-    pub fn map<U:Clone>(&self, op: &fn(&T) -> U) -> Result<U,E> {
-        match *self {
-            Ok(ref t) => Ok(op(t)),
-            Err(ref e) => Err(e.clone())
+#[inline]
+#[allow(missing_doc)]
+pub fn map_opt<T, U: ToStr, V>(o_t: &Option<T>,
+                               op: &fn(&T) -> Result<V,U>) -> Result<Option<V>,U> {
+    match *o_t {
+        None => Ok(None),
+        Some(ref t) => match op(t) {
+            Ok(v) => Ok(Some(v)),
+            Err(e) => Err(e)
         }
     }
 }
 
-/**
- * Maps each element in the vector `ts` using the operation `op`.  Should an
- * error occur, no further mappings are performed and the error is returned.
- * Should no error occur, a vector containing the result of each map is
- * returned.
- *
- * Here is an example which increments every integer in a vector,
- * checking for overflow:
- *
- *     fn inc_conditionally(x: uint) -> result<uint,str> {
- *         if x == uint::max_value { return Err("overflow"); }
- *         else { return Ok(x+1u); }
- *     }
- *     map(~[1u, 2u, 3u], inc_conditionally).chain {|incd|
- *         assert!(incd == ~[2u, 3u, 4u]);
- *     }
- */
+// FIXME: #8228 Replaceable by an external iterator?
+/// Maps each element in the vector `ts` using the operation `op`.  Should an
+/// error occur, no further mappings are performed and the error is returned.
+/// Should no error occur, a vector containing the result of each map is
+/// returned.
+///
+/// Here is an example which increments every integer in a vector,
+/// checking for overflow:
+///
+///     fn inc_conditionally(x: uint) -> result<uint,str> {
+///         if x == uint::max_value { return Err("overflow"); }
+///         else { return Ok(x+1u); }
+///     }
+///     map(~[1u, 2u, 3u], inc_conditionally).chain {|incd|
+///         assert!(incd == ~[2u, 3u, 4u]);
+///     }
 #[inline]
 pub fn map_vec<T,U,V>(ts: &[T], op: &fn(&T) -> Result<V,U>)
                       -> Result<~[V],U> {
@@ -272,36 +264,17 @@ pub fn map_vec<T,U,V>(ts: &[T], op: &fn(&T) -> Result<V,U>)
     return Ok(vs);
 }
 
+// FIXME: #8228 Replaceable by an external iterator?
+/// Same as map, but it operates over two parallel vectors.
+///
+/// A precondition is used here to ensure that the vectors are the same
+/// length.  While we do not often use preconditions in the standard
+/// library, a precondition is used here because result::t is generally
+/// used in 'careful' code contexts where it is both appropriate and easy
+/// to accommodate an error like the vectors being of different lengths.
 #[inline]
-#[allow(missing_doc)]
-pub fn map_opt<T,
-               U,
-               V>(
-               o_t: &Option<T>,
-               op: &fn(&T) -> Result<V,U>)
-               -> Result<Option<V>,U> {
-    match *o_t {
-        None => Ok(None),
-        Some(ref t) => match op(t) {
-            Ok(v) => Ok(Some(v)),
-            Err(e) => Err(e)
-        }
-    }
-}
-
-/**
- * Same as map, but it operates over two parallel vectors.
- *
- * A precondition is used here to ensure that the vectors are the same
- * length.  While we do not often use preconditions in the standard
- * library, a precondition is used here because result::t is generally
- * used in 'careful' code contexts where it is both appropriate and easy
- * to accommodate an error like the vectors being of different lengths.
- */
-#[inline]
-pub fn map_vec2<S,T,U,V>(ss: &[S], ts: &[T],
-                op: &fn(&S,&T) -> Result<V,U>) -> Result<~[V],U> {
-
+pub fn map_vec2<S, T, U: ToStr, V>(ss: &[S], ts: &[T],
+                                   op: &fn(&S,&T) -> Result<V,U>) -> Result<~[V],U> {
     assert!(vec::same_length(ss, ts));
     let n = ts.len();
     let mut vs = vec::with_capacity(n);
@@ -316,15 +289,13 @@ pub fn map_vec2<S,T,U,V>(ss: &[S], ts: &[T],
     return Ok(vs);
 }
 
-/**
- * Applies op to the pairwise elements from `ss` and `ts`, aborting on
- * error.  This could be implemented using `map_zip()` but it is more efficient
- * on its own as no result vector is built.
- */
+// FIXME: #8228 Replaceable by an external iterator?
+/// Applies op to the pairwise elements from `ss` and `ts`, aborting on
+/// error.  This could be implemented using `map_zip()` but it is more efficient
+/// on its own as no result vector is built.
 #[inline]
-pub fn iter_vec2<S,T,U>(ss: &[S], ts: &[T],
-                         op: &fn(&S,&T) -> Result<(),U>) -> Result<(),U> {
-
+pub fn iter_vec2<S, T, U: ToStr>(ss: &[S], ts: &[T],
+                                 op: &fn(&S,&T) -> Result<(),U>) -> Result<(),U> {
     assert!(vec::same_length(ss, ts));
     let n = ts.len();
     let mut i = 0u;
@@ -353,12 +324,12 @@ mod tests {
 
     #[test]
     pub fn chain_success() {
-        assert_eq!(op1().chain(op2).get(), 667u);
+        assert_eq!(op1().chain(op2).unwrap(), 667u);
     }
 
     #[test]
     pub fn chain_failure() {
-        assert_eq!(op3().chain( op2).get_err(), ~"sadface");
+        assert_eq!(op3().chain( op2).unwrap_err(), ~"sadface");
     }
 
     #[test]
diff --git a/src/libstd/rt/io/flate.rs b/src/libstd/rt/io/flate.rs
index e57b80658ee..bea62f7e28c 100644
--- a/src/libstd/rt/io/flate.rs
+++ b/src/libstd/rt/io/flate.rs
@@ -115,7 +115,7 @@ mod test {
         let mem_reader = MemReader::new(buf);
         let mut inflate_reader = InflateReader::new(mem_reader);
         let mut out_bytes = [0, .. 100];
-        let bytes_read = inflate_reader.read(out_bytes).get();
+        let bytes_read = inflate_reader.read(out_bytes).unwrap();
         assert_eq!(bytes_read, in_bytes.len());
         let out_msg = str::from_bytes(out_bytes);
         assert!(in_msg == out_msg);
diff --git a/src/libstd/rt/io/mod.rs b/src/libstd/rt/io/mod.rs
index 838c2d86c9f..c980dc9d73e 100644
--- a/src/libstd/rt/io/mod.rs
+++ b/src/libstd/rt/io/mod.rs
@@ -243,6 +243,8 @@ Out of scope
 */
 
 use prelude::*;
+use to_str::ToStr;
+use str::{StrSlice, OwnedStr};
 
 // Reexports
 pub use self::stdio::stdin;
@@ -334,6 +336,20 @@ pub struct IoError {
     detail: Option<~str>
 }
 
+// FIXME: #8242 implementing manually because deriving doesn't work for some reason
+impl ToStr for IoError {
+    fn to_str(&self) -> ~str {
+        let mut s = ~"IoError { kind: ";
+        s.push_str(self.kind.to_str());
+        s.push_str(", desc: ");
+        s.push_str(self.desc);
+        s.push_str(", detail: ");
+        s.push_str(self.detail.to_str());
+        s.push_str(" }");
+        s
+    }
+}
+
 #[deriving(Eq)]
 pub enum IoErrorKind {
     PreviousIoError,
@@ -348,6 +364,24 @@ pub enum IoErrorKind {
     BrokenPipe
 }
 
+// FIXME: #8242 implementing manually because deriving doesn't work for some reason
+impl ToStr for IoErrorKind {
+    fn to_str(&self) -> ~str {
+        match *self {
+            PreviousIoError => ~"PreviousIoError",
+            OtherIoError => ~"OtherIoError",
+            EndOfFile => ~"EndOfFile",
+            FileNotFound => ~"FileNotFound",
+            PermissionDenied => ~"PermissionDenied",
+            ConnectionFailed => ~"ConnectionFailed",
+            Closed => ~"Closed",
+            ConnectionRefused => ~"ConnectionRefused",
+            ConnectionReset => ~"ConnectionReset",
+            BrokenPipe => ~"BrokenPipe"
+        }
+    }
+}
+
 // XXX: Can't put doc comments on macros
 // Raised by `I/O` operations on error.
 condition! {
@@ -505,4 +539,4 @@ pub fn placeholder_error() -> IoError {
         desc: "Placeholder error. You shouldn't be seeing this",
         detail: None
     }
-}
\ No newline at end of file
+}
diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs
index 33e83fd9040..760ca8a9ada 100644
--- a/src/libstd/rt/mod.rs
+++ b/src/libstd/rt/mod.rs
@@ -365,7 +365,7 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
 
         rtdebug!("about to create the main scheduler task");
 
-        let mut main_sched = main_sched.get();
+        let mut main_sched = main_sched.unwrap();
 
         let home = Sched(main_sched.make_handle());
         let mut main_task = ~Task::new_root_homed(&mut main_sched.stack_pool,
diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs
index cb949edd7bb..4c5e4bdc3c1 100644
--- a/src/libstd/rt/task.rs
+++ b/src/libstd/rt/task.rs
@@ -465,10 +465,10 @@ mod test {
         do run_in_newsched_task() {
             static key: local_data::Key<@~str> = &local_data::Key;
             local_data::set(key, @~"data");
-            assert!(*local_data::get(key, |k| k.map(|&k| *k)).get() == ~"data");
+            assert!(*local_data::get(key, |k| k.map(|&k| *k)).unwrap() == ~"data");
             static key2: local_data::Key<@~str> = &local_data::Key;
             local_data::set(key2, @~"data");
-            assert!(*local_data::get(key2, |k| k.map(|&k| *k)).get() == ~"data");
+            assert!(*local_data::get(key2, |k| k.map(|&k| *k)).unwrap() == ~"data");
         }
     }
 
diff --git a/src/libstd/rt/test.rs b/src/libstd/rt/test.rs
index 2427da01a0c..8b5215ae969 100644
--- a/src/libstd/rt/test.rs
+++ b/src/libstd/rt/test.rs
@@ -154,7 +154,7 @@ pub fn run_in_mt_newsched_task(f: ~fn()) {
 
     do run_in_bare_thread {
         let nthreads = match os::getenv("RUST_RT_TEST_THREADS") {
-            Some(nstr) => FromStr::from_str(nstr).get(),
+            Some(nstr) => FromStr::from_str(nstr).unwrap(),
             None => {
                 // Using more threads than cores in test code
                 // to force the OS to preempt them frequently.
@@ -362,7 +362,7 @@ pub fn stress_factor() -> uint {
     use os::getenv;
 
     match getenv("RUST_RT_STRESS") {
-        Some(val) => uint::from_str(val).get(),
+        Some(val) => uint::from_str(val).unwrap(),
         None => 1
     }
 }
diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs
index a1169954688..40e5c8d4bf1 100644
--- a/src/libstd/rt/util.rs
+++ b/src/libstd/rt/util.rs
@@ -31,7 +31,7 @@ pub fn num_cpus() -> uint {
 /// either `RUST_THREADS` or `num_cpus`.
 pub fn default_sched_threads() -> uint {
     match os::getenv("RUST_THREADS") {
-        Some(nstr) => FromStr::from_str(nstr).get(),
+        Some(nstr) => FromStr::from_str(nstr).unwrap(),
         None => num_cpus()
     }
 }
@@ -118,4 +118,4 @@ pub fn get_exit_status() -> int {
     extern {
         fn rust_get_exit_status_newrt() -> libc::uintptr_t;
     }
-}
\ No newline at end of file
+}
diff --git a/src/libstd/rt/uv/net.rs b/src/libstd/rt/uv/net.rs
index 67d3bbef8a9..fd3042899f6 100644
--- a/src/libstd/rt/uv/net.rs
+++ b/src/libstd/rt/uv/net.rs
@@ -108,7 +108,7 @@ fn uv_socket_addr_as_socket_addr<T>(addr: UvSocketAddr, f: &fn(SocketAddr) -> T)
                             "" => ~[],
                             // IPv4-Mapped/Compatible IPv6 Address?
                             s if s.find('.').is_some() => {
-                                let i = s.rfind(':').get_or_default(-1);
+                                let i = s.rfind(':').unwrap_or_default(-1);
 
                                 let b = s.slice(i + 1, s.len()); // the ipv4 part
 
@@ -614,7 +614,7 @@ mod test {
             do tcp_watcher.connect(addr) |stream_watcher, status| {
                 rtdebug!("tcp_watcher.connect!");
                 assert!(status.is_some());
-                assert_eq!(status.get().name(), ~"ECONNREFUSED");
+                assert_eq!(status.unwrap().name(), ~"ECONNREFUSED");
                 stream_watcher.close(||());
             }
             loop_.run();
@@ -632,7 +632,7 @@ mod test {
             do tcp_watcher.connect(addr) |stream_watcher, status| {
                 rtdebug!("tcp_watcher.connect!");
                 assert!(status.is_some());
-                assert_eq!(status.get().name(), ~"ECONNREFUSED");
+                assert_eq!(status.unwrap().name(), ~"ECONNREFUSED");
                 stream_watcher.close(||());
             }
             loop_.run();
diff --git a/src/libstd/rt/uv/uvio.rs b/src/libstd/rt/uv/uvio.rs
index 85cf660a5f1..70a397199ab 100644
--- a/src/libstd/rt/uv/uvio.rs
+++ b/src/libstd/rt/uv/uvio.rs
@@ -278,7 +278,7 @@ impl IoFactory for UvIoFactory {
                     rtdebug!("status is some");
                     let task_cell = Cell::new(task_cell.take());
                     do stream_watcher.close {
-                        let res = Err(uv_error_to_io_error(status.get()));
+                        let res = Err(uv_error_to_io_error(status.unwrap()));
                         unsafe { (*result_cell_ptr).put_back(res); }
                         let scheduler = Local::take::<Scheduler>();
                         scheduler.resume_blocked_task_immediately(task_cell.take());
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index 1a913fb4e99..95a411a3f96 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -58,7 +58,7 @@ pub fn from_bytes(vv: &[u8]) -> ~str {
     use str::not_utf8::cond;
 
     if !is_utf8(vv) {
-        let first_bad_byte = *vv.iter().find_(|&b| !is_utf8([*b])).get();
+        let first_bad_byte = *vv.iter().find_(|&b| !is_utf8([*b])).unwrap();
         cond.raise(fmt!("from_bytes: input is not UTF-8; first bad byte is %u",
                         first_bad_byte as uint))
     } else {
@@ -75,7 +75,7 @@ pub fn from_bytes_owned(vv: ~[u8]) -> ~str {
     use str::not_utf8::cond;
 
     if !is_utf8(vv) {
-        let first_bad_byte = *vv.iter().find_(|&b| !is_utf8([*b])).get();
+        let first_bad_byte = *vv.iter().find_(|&b| !is_utf8([*b])).unwrap();
         cond.raise(fmt!("from_bytes: input is not UTF-8; first bad byte is %u",
                         first_bad_byte as uint))
     } else {
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs
index f7a943f8d2f..225a4b8cfd2 100644
--- a/src/libstd/task/mod.rs
+++ b/src/libstd/task/mod.rs
@@ -926,7 +926,7 @@ fn test_named_task() {
         t.name(~"ada lovelace");
         do t.spawn {
             do with_task_name |name| {
-                assert!(name.get() == "ada lovelace");
+                assert!(name.unwrap() == "ada lovelace");
             }
         }
     }
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index f037aa2b7e7..4d4437cc963 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -195,10 +195,8 @@ pub fn build<A>(builder: &fn(push: &fn(v: A))) -> ~[A] {
  *             onto the vector being constructed.
  */
 #[inline]
-pub fn build_sized_opt<A>(size: Option<uint>,
-                          builder: &fn(push: &fn(v: A)))
-                       -> ~[A] {
-    build_sized(size.get_or_default(4), builder)
+pub fn build_sized_opt<A>(size: Option<uint>, builder: &fn(push: &fn(v: A))) -> ~[A] {
+    build_sized(size.unwrap_or_default(4), builder)
 }
 
 /// An iterator over the slices of a vector separated by elements that