From 07dc8d67c92017f950eef3951ec901cb2a3add7e Mon Sep 17 00:00:00 2001 From: Cody P Schafer Date: Wed, 25 Feb 2015 13:37:22 -0500 Subject: 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) -> Result becomes fn or(self, res: Result) -> Result 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. --- src/libcore/result.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libcore') 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 Result { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn or(self, res: Result) -> Result { + pub fn or(self, res: Result) -> Result { match self { - Ok(_) => self, + Ok(v) => Ok(v), Err(_) => res, } } -- cgit 1.4.1-3-g733a5