summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorCody P Schafer <dev@codyps.com>2015-02-25 13:37:22 -0500
committerCody P Schafer <dev@codyps.com>2015-02-25 17:38:28 -0500
commit07dc8d67c92017f950eef3951ec901cb2a3add7e (patch)
tree1ddc060d09dc610bd642ffef510fc95da28d5574 /src/libcore
parent880fb89bde126aa43fc348d0b93839d3d18a1f51 (diff)
downloadrust-07dc8d67c92017f950eef3951ec901cb2a3add7e.tar.gz
rust-07dc8d67c92017f950eef3951ec901cb2a3add7e.zip
Result::or : avoid over-specializing the type
Changes .or() so that it can return a Result with a different E type
than the one it is called on.

Essentially:

    fn or(self, res: Result<T, E>) -> Result<T, E>

becomes

    fn or<F>(self, res: Result<T, F>) -> Result<T, F>

This brings `or` in line with the existing `and` and `or_else` member
types.

This is a
[breaking-change]
Due to some code needing additional type annotations.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/result.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 23e936a75d7..ec0c19d36e4 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -641,9 +641,9 @@ impl<T, E> Result<T, E> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn or(self, res: Result<T, E>) -> Result<T, E> {
+    pub fn or<F>(self, res: Result<T, F>) -> Result<T, F> {
         match self {
-            Ok(_) => self,
+            Ok(v) => Ok(v),
             Err(_) => res,
         }
     }