Skip to content

Commit 563d63b

Browse files
Thiezthestinger
authored andcommitted
---
yaml --- r: 64491 b: refs/heads/snap-stage3 c: eb74f0c h: refs/heads/master i: 64489: 18fd3d7 64487: 271148a v: v3
1 parent b856a88 commit 563d63b

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: ddd8c156c650347267e4b02938f8efb207cb2150
4+
refs/heads/snap-stage3: eb74f0ccf60a1e8dda1afe9a3be0e8dd4fd96f9f
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)