Skip to content

Commit 5f8984f

Browse files
committed
---
yaml --- r: 64791 b: refs/heads/snap-stage3 c: 4eb95f6 h: refs/heads/master i: 64789: 4f4f30c 64787: e1bbdf5 64783: f0d577c v: v3
1 parent 4c5aa14 commit 5f8984f

File tree

2 files changed

+49
-48
lines changed

2 files changed

+49
-48
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 225f1c760d998b2f26107c3938d4ca8baa57c6c0
4+
refs/heads/snap-stage3: 4eb95f6d1c22419b50980d0bf8effc6e2f22feb5
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/result.rs

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,6 @@ pub fn get_err<T, U: Clone>(res: &Result<T, U>) -> U {
6262
}
6363
}
6464

65-
/// Returns true if the result is `ok`
66-
#[inline]
67-
pub fn is_ok<T, U>(res: &Result<T, U>) -> bool {
68-
match *res {
69-
Ok(_) => true,
70-
Err(_) => false
71-
}
72-
}
73-
74-
/// Returns true if the result is `err`
75-
#[inline]
76-
pub fn is_err<T, U>(res: &Result<T, U>) -> bool {
77-
!is_ok(res)
78-
}
79-
8065
/**
8166
* Convert to the `either` type
8267
*
@@ -134,27 +119,8 @@ pub fn chain_err<T, U, V>(
134119
}
135120
}
136121

137-
/**
138-
* Call a function based on a previous result
139-
*
140-
* If `res` is `ok` then the value is extracted and passed to `op` whereupon
141-
* `op`s result is returned. if `res` is `err` then it is immediately
142-
* returned. This function can be used to compose the results of two
143-
* functions.
144-
*
145-
* Example:
146-
*
147-
* iter(read_file(file)) { |buf|
148-
* print_buf(buf)
149-
* }
150-
*/
151-
#[inline]
152-
pub fn iter<T, E>(res: &Result<T, E>, f: &fn(&T)) {
153-
match *res {
154-
Ok(ref t) => f(t),
155-
Err(_) => ()
156-
}
157-
}
122+
123+
158124

159125
/**
160126
* Call a function based on a previous result
@@ -164,13 +130,7 @@ pub fn iter<T, E>(res: &Result<T, E>, f: &fn(&T)) {
164130
* This function can be used to pass through a successful result while
165131
* handling an error.
166132
*/
167-
#[inline]
168-
pub fn iter_err<T, E>(res: &Result<T, E>, f: &fn(&E)) {
169-
match *res {
170-
Ok(_) => (),
171-
Err(ref e) => f(e)
172-
}
173-
}
133+
174134

175135
/**
176136
* Call a function based on a previous result
@@ -229,17 +189,58 @@ impl<T, E> Result<T, E> {
229189
}
230190
}
231191

192+
/// Returns true if the result is `ok`
232193
#[inline]
233-
pub fn is_ok(&self) -> bool { is_ok(self) }
194+
pub fn is_ok(&self) -> bool {
195+
match *self {
196+
Ok(_) => true,
197+
Err(_) => false
198+
}
199+
}
234200

201+
/// Returns true if the result is `err`
235202
#[inline]
236-
pub fn is_err(&self) -> bool { is_err(self) }
203+
pub fn is_err(&self) -> bool {
204+
!self.is_ok()
205+
}
237206

207+
/**
208+
* Call a function based on a previous result
209+
*
210+
* If `*self` is `ok` then the value is extracted and passed to `op` whereupon
211+
* `op`s result is returned. if `res` is `err` then it is immediately
212+
* returned. This function can be used to compose the results of two
213+
* functions.
214+
*
215+
* Example:
216+
*
217+
* read_file(file).iter() { |buf|
218+
* print_buf(buf)
219+
* }
220+
*/
238221
#[inline]
239-
pub fn iter(&self, f: &fn(&T)) { iter(self, f) }
222+
pub fn iter(&self, f: &fn(&T)) {
223+
match *self {
224+
Ok(ref t) => f(t),
225+
Err(_) => ()
226+
}
227+
}
240228

229+
/**
230+
* Call a function based on a previous result
231+
*
232+
* If `*self` is `err` then the value is extracted and passed to `op` whereupon
233+
* `op`s result is returned. if `res` is `ok` then it is immediately returned.
234+
* This function can be used to pass through a successful result while
235+
* handling an error.
236+
*/
241237
#[inline]
242-
pub fn iter_err(&self, f: &fn(&E)) { iter_err(self, f) }
238+
pub fn iter_err(&self, f: &fn(&E)) {
239+
match *self {
240+
Ok(_) => (),
241+
Err(ref e) => f(e)
242+
}
243+
}
243244

244245
#[inline]
245246
pub fn unwrap(self) -> T { unwrap(self) }

0 commit comments

Comments
 (0)