Skip to content

Commit bb4f478

Browse files
Thiezthestinger
authored andcommitted
---
yaml --- r: 69118 b: refs/heads/auto c: eb74f0c h: refs/heads/master v: v3
1 parent e882190 commit bb4f478

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: ddd8c156c650347267e4b02938f8efb207cb2150
17+
refs/heads/auto: eb74f0ccf60a1e8dda1afe9a3be0e8dd4fd96f9f
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libextra/future.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ impl<A:Clone> Future<A> {
6060
}
6161
}
6262

63+
impl<A> Future<A> {
64+
/// Gets the value from this future, forcing evaluation.
65+
pub fn unwrap(self) -> A {
66+
let mut this = self;
67+
this.get_ref();
68+
let state = replace(&mut this.state, Evaluating);
69+
match state {
70+
Forced(v) => v,
71+
_ => fail!( "Logic error." ),
72+
}
73+
}
74+
}
75+
6376
impl<A> Future<A> {
6477
pub fn get_ref<'a>(&'a mut self) -> &'a A {
6578
/*!
@@ -179,6 +192,12 @@ mod test {
179192
assert_eq!(f.get(), ~"fail");
180193
}
181194
195+
#[test]
196+
fn test_interface_unwrap() {
197+
let mut f = from_value(~"fail");
198+
assert_eq!(f.unwrap(), ~"fail");
199+
}
200+
182201
#[test]
183202
fn test_get_ref_method() {
184203
let mut f = from_value(22);

0 commit comments

Comments
 (0)