Skip to content

Commit 0cf730e

Browse files
committed
core: Split up result extensions by kind bounds
1 parent ce7b803 commit 0cf730e

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

src/libcore/result.rs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,11 @@ fn map_err<T: copy, E, F: copy>(res: result<T, E>, op: fn(E) -> F)
180180
}
181181
}
182182

183-
impl extensions<T:copy, E:copy> for result<T,E> {
184-
fn get() -> T { get(self) }
185-
186-
fn get_err() -> E { get_err(self) }
187-
183+
impl extensions<T, E> for result<T, E> {
188184
fn is_success() -> bool { is_success(self) }
189185

190186
fn is_failure() -> bool { is_failure(self) }
191187

192-
fn chain<U:copy>(op: fn(T) -> result<U,E>) -> result<U,E> {
193-
chain(self, op)
194-
}
195-
196-
fn chain_err<F:copy>(op: fn(E) -> result<T,F>) -> result<T,F> {
197-
chain_err(self, op)
198-
}
199-
200188
fn iter(f: fn(T)) {
201189
alt self {
202190
ok(t) { f(t) }
@@ -210,19 +198,37 @@ impl extensions<T:copy, E:copy> for result<T,E> {
210198
err(e) { f(e) }
211199
}
212200
}
201+
}
202+
203+
impl extensions<T:copy, E> for result<T, E> {
204+
fn get() -> T { get(self) }
205+
206+
fn map_err<F:copy>(op: fn(E) -> F) -> result<T,F> {
207+
alt self {
208+
ok(t) { ok(t) }
209+
err(e) { err(op(e)) }
210+
}
211+
}
212+
}
213+
214+
impl extensions<T, E:copy> for result<T, E> {
215+
fn get_err() -> E { get_err(self) }
213216

214217
fn map<U:copy>(op: fn(T) -> U) -> result<U,E> {
215218
alt self {
216219
ok(t) { ok(op(t)) }
217220
err(e) { err(e) }
218221
}
219222
}
223+
}
220224

221-
fn map_err<F:copy>(op: fn(E) -> F) -> result<T,F> {
222-
alt self {
223-
ok(t) { ok(t) }
224-
err(e) { err(op(e)) }
225-
}
225+
impl extensions<T:copy, E:copy> for result<T,E> {
226+
fn chain<U:copy>(op: fn(T) -> result<U,E>) -> result<U,E> {
227+
chain(self, op)
228+
}
229+
230+
fn chain_err<F:copy>(op: fn(E) -> result<T,F>) -> result<T,F> {
231+
chain_err(self, op)
226232
}
227233
}
228234

0 commit comments

Comments
 (0)