Skip to content

Commit 225f1c7

Browse files
committed
cleanup get_ref
1 parent 3078e83 commit 225f1c7

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/libstd/result.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,6 @@ pub fn get<T:Clone,U>(res: &Result<T, U>) -> T {
4747
}
4848
}
4949

50-
/**
51-
* Get a reference to the value out of a successful result
52-
*
53-
* # Failure
54-
*
55-
* If the result is an error
56-
*/
57-
#[inline]
58-
pub fn get_ref<'a, T, U>(res: &'a Result<T, U>) -> &'a T {
59-
match *res {
60-
Ok(ref t) => t,
61-
Err(ref the_err) =>
62-
fail!("get_ref called on error result: %?", *the_err)
63-
}
64-
}
65-
6650
/**
6751
* Get the value out of an error result
6852
*
@@ -229,8 +213,21 @@ pub fn map_err<T:Clone,E,F:Clone>(res: &Result<T, E>, op: &fn(&E) -> F)
229213
}
230214

231215
impl<T, E> Result<T, E> {
216+
/**
217+
* Get a reference to the value out of a successful result
218+
*
219+
* # Failure
220+
*
221+
* If the result is an error
222+
*/
232223
#[inline]
233-
pub fn get_ref<'a>(&'a self) -> &'a T { get_ref(self) }
224+
pub fn get_ref<'a>(&'a self) -> &'a T {
225+
match *self {
226+
Ok(ref t) => t,
227+
Err(ref the_err) =>
228+
fail!("get_ref called on error result: %?", *the_err)
229+
}
230+
}
234231

235232
#[inline]
236233
pub fn is_ok(&self) -> bool { is_ok(self) }

0 commit comments

Comments
 (0)