Skip to content

Commit 22c7e5d

Browse files
committed
---
yaml --- r: 143325 b: refs/heads/try2 c: e308167 h: refs/heads/master i: 143323: 8f10ac1 v: v3
1 parent da318f2 commit 22c7e5d

File tree

4 files changed

+18
-26
lines changed

4 files changed

+18
-26
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 4eb95f6d1c22419b50980d0bf8effc6e2f22feb5
8+
refs/heads/try2: e308167a2fe558924fcebcc99358c057ae0b90b4
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/workcache.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use std::cell::Cell;
2222
use std::comm::{PortOne, oneshot, send_one, recv_one};
2323
use std::either::{Either, Left, Right};
2424
use std::io;
25-
use std::result;
2625
use std::run;
2726
use std::task;
2827

@@ -208,7 +207,7 @@ fn json_encode<T:Encodable<json::Encoder>>(t: &T) -> ~str {
208207
// FIXME(#5121)
209208
fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
210209
do io::with_str_reader(s) |rdr| {
211-
let j = result::unwrap(json::from_reader(rdr));
210+
let j = json::from_reader(rdr).unwrap();
212211
let mut decoder = json::Decoder(j);
213212
Decodable::decode(&mut decoder)
214213
}

branches/try2/src/libstd/io.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,12 +1851,10 @@ mod tests {
18511851
~"A hoopy frood who really knows where his towel is.";
18521852
debug!(frood.clone());
18531853
{
1854-
let out: @io::Writer =
1855-
result::unwrap(
1856-
io::file_writer(tmpfile, [io::Create, io::Truncate]));
1854+
let out: @io::Writer = io::file_writer(tmpfile, [io::Create, io::Truncate]).unwrap();
18571855
out.write_str(frood);
18581856
}
1859-
let inp: @io::Reader = result::unwrap(io::file_reader(tmpfile));
1857+
let inp: @io::Reader = io::file_reader(tmpfile).unwrap();
18601858
let frood2: ~str = inp.read_c_str();
18611859
debug!(frood2.clone());
18621860
assert_eq!(frood, frood2);

branches/try2/src/libstd/result.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,23 @@ impl<T, E> Result<T, E> {
242242
}
243243
}
244244

245+
/// Unwraps a result, assuming it is an `ok(T)`
245246
#[inline]
246-
pub fn unwrap(self) -> T { unwrap(self) }
247+
pub fn unwrap(self) -> T {
248+
match self {
249+
Ok(t) => t,
250+
Err(_) => fail!("unwrap called on an err result")
251+
}
252+
}
247253

254+
/// Unwraps a result, assuming it is an `err(U)`
248255
#[inline]
249-
pub fn unwrap_err(self) -> E { unwrap_err(self) }
256+
pub fn unwrap_err(self) -> E {
257+
match self {
258+
Err(u) => u,
259+
Ok(_) => fail!("unwrap called on an ok result")
260+
}
261+
}
250262

251263
#[inline]
252264
pub fn chain<U>(self, op: &fn(T) -> Result<U,E>) -> Result<U,E> {
@@ -375,23 +387,6 @@ pub fn iter_vec2<S,T,U>(ss: &[S], ts: &[T],
375387
return Ok(());
376388
}
377389

378-
/// Unwraps a result, assuming it is an `ok(T)`
379-
#[inline]
380-
pub fn unwrap<T, U>(res: Result<T, U>) -> T {
381-
match res {
382-
Ok(t) => t,
383-
Err(_) => fail!("unwrap called on an err result")
384-
}
385-
}
386-
387-
/// Unwraps a result, assuming it is an `err(U)`
388-
#[inline]
389-
pub fn unwrap_err<T, U>(res: Result<T, U>) -> U {
390-
match res {
391-
Err(u) => u,
392-
Ok(_) => fail!("unwrap called on an ok result")
393-
}
394-
}
395390

396391
#[cfg(test)]
397392
mod tests {

0 commit comments

Comments
 (0)