From 0cf730ed2a94718229fd2c0a3ded8fc2b18ee6ce Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 22 Jun 2012 17:32:52 -0700 Subject: [PATCH] core: Split up result extensions by kind bounds --- src/libcore/result.rs | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 3c6622ba69d..a5badd92610 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -180,23 +180,11 @@ fn map_err(res: result, op: fn(E) -> F) } } -impl extensions for result { - fn get() -> T { get(self) } - - fn get_err() -> E { get_err(self) } - +impl extensions for result { fn is_success() -> bool { is_success(self) } fn is_failure() -> bool { is_failure(self) } - fn chain(op: fn(T) -> result) -> result { - chain(self, op) - } - - fn chain_err(op: fn(E) -> result) -> result { - chain_err(self, op) - } - fn iter(f: fn(T)) { alt self { ok(t) { f(t) } @@ -210,6 +198,21 @@ fn iter_err(f: fn(E)) { err(e) { f(e) } } } +} + +impl extensions for result { + fn get() -> T { get(self) } + + fn map_err(op: fn(E) -> F) -> result { + alt self { + ok(t) { ok(t) } + err(e) { err(op(e)) } + } + } +} + +impl extensions for result { + fn get_err() -> E { get_err(self) } fn map(op: fn(T) -> U) -> result { alt self { @@ -217,12 +220,15 @@ fn map(op: fn(T) -> U) -> result { err(e) { err(e) } } } +} - fn map_err(op: fn(E) -> F) -> result { - alt self { - ok(t) { ok(t) } - err(e) { err(op(e)) } - } +impl extensions for result { + fn chain(op: fn(T) -> result) -> result { + chain(self, op) + } + + fn chain_err(op: fn(E) -> result) -> result { + chain_err(self, op) } } -- GitLab