Skip to content

Commit 3688318

Browse files
committed
De-mode core::future.
1 parent bc6eaf2 commit 3688318

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

src/libcore/future.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// NB: transitionary, de-mode-ing.
2+
#[forbid(deprecated_mode)];
3+
#[forbid(deprecated_pattern)];
4+
15
/*!
26
* A type representing values that may be computed concurrently and
37
* operations for working with them.
@@ -37,13 +41,13 @@ impl<A:copy send> future<A> {
3741
fn get() -> A {
3842
//! Get the value of the future
3943
40-
get(self)
44+
get(&self)
4145
}
4246

43-
fn with<B>(blk: fn(A) -> B) -> B {
47+
fn with<B>(blk: fn((&A)) -> B) -> B {
4448
//! Work with the value without copying it
4549
46-
with(self, blk)
50+
with(&self, blk)
4751
}
4852
}
4953

@@ -64,7 +68,7 @@ macro_rules! move_it {
6468
{$x:expr} => { unsafe { let y <- *ptr::addr_of($x); y } }
6569
}
6670

67-
fn from_port<A:send>(-port: future_pipe::client::waiting<A>) -> future<A> {
71+
fn from_port<A:send>(+port: future_pipe::client::waiting<A>) -> future<A> {
6872
#[doc = "
6973
Create a future from a port
7074
@@ -110,13 +114,13 @@ fn spawn<A:send>(+blk: fn~() -> A) -> future<A> {
110114
}))
111115
}
112116

113-
fn get<A:copy>(future: future<A>) -> A {
117+
fn get<A:copy>(future: &future<A>) -> A {
114118
//! Get the value of the future
115119
116-
do with(future) |v| { v }
120+
do with(future) |v| { *v }
117121
}
118122

119-
fn with<A,B>(future: future<A>, blk: fn(A) -> B) -> B {
123+
fn with<A,B>(future: &future<A>, blk: fn((&A)) -> B) -> B {
120124
//! Work with the value without copying it
121125
122126
let v = match copy future.v {
@@ -127,7 +131,7 @@ fn with<A,B>(future: future<A>, blk: fn(A) -> B) -> B {
127131
v
128132
}
129133
};
130-
blk(*v)
134+
blk(v)
131135
}
132136

133137
proto! future_pipe {
@@ -139,22 +143,22 @@ proto! future_pipe {
139143
#[test]
140144
fn test_from_value() {
141145
let f = from_value(~"snail");
142-
assert get(f) == ~"snail";
146+
assert get(&f) == ~"snail";
143147
}
144148

145149
#[test]
146150
fn test_from_port() {
147151
let (po, ch) = future_pipe::init();
148152
future_pipe::server::completed(ch, ~"whale");
149153
let f = from_port(po);
150-
assert get(f) == ~"whale";
154+
assert get(&f) == ~"whale";
151155
}
152156

153157
#[test]
154158
fn test_from_fn() {
155159
let f = fn@() -> ~str { ~"brail" };
156160
let f = from_fn(f);
157-
assert get(f) == ~"brail";
161+
assert get(&f) == ~"brail";
158162
}
159163

160164
#[test]
@@ -166,25 +170,25 @@ fn test_interface_get() {
166170
#[test]
167171
fn test_with() {
168172
let f = from_value(~"nail");
169-
assert with(f, |v| v) == ~"nail";
173+
assert with(&f, |v| *v) == ~"nail";
170174
}
171175

172176
#[test]
173177
fn test_interface_with() {
174178
let f = from_value(~"kale");
175-
assert f.with(|v| v) == ~"kale";
179+
assert f.with(|v| *v) == ~"kale";
176180
}
177181

178182
#[test]
179183
fn test_spawn() {
180184
let f = spawn(|| ~"bale");
181-
assert get(f) == ~"bale";
185+
assert get(&f) == ~"bale";
182186
}
183187

184188
#[test]
185189
#[should_fail]
186190
#[ignore(cfg(target_os = "win32"))]
187191
fn test_futurefail() {
188192
let f = spawn(|| fail);
189-
let _x: ~str = get(f);
193+
let _x: ~str = get(&f);
190194
}

src/libcore/task.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ impl task_builder {
409409
do self.future_result(|+r| { result = some(r); }).spawn {
410410
comm::send(ch, f());
411411
}
412-
match future::get(option::unwrap(result)) {
412+
match future::get(&option::unwrap(result)) {
413413
success => result::ok(comm::recv(po)),
414414
failure => result::err(())
415415
}
@@ -1704,13 +1704,13 @@ fn test_add_wrapper() {
17041704
fn test_future_result() {
17051705
let mut result = none;
17061706
do task().future_result(|+r| { result = some(r); }).spawn { }
1707-
assert future::get(option::unwrap(result)) == success;
1707+
assert future::get(&option::unwrap(result)) == success;
17081708

17091709
result = none;
17101710
do task().future_result(|+r| { result = some(r); }).unlinked().spawn {
17111711
fail;
17121712
}
1713-
assert future::get(option::unwrap(result)) == failure;
1713+
assert future::get(&option::unwrap(result)) == failure;
17141714
}
17151715

17161716
#[test] #[should_fail] #[ignore(cfg(windows))]

src/libstd/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ mod tests {
429429
}
430430
}
431431
// Wait for children to pass their asserts
432-
for vec::each(children) |r| { future::get(r); }
432+
for vec::each(children) |r| { future::get(&r); }
433433
// Wait for writer to finish
434434
p.recv();
435435
do arc.read |num| { assert *num == 10; }

src/libstd/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ fn run_test(+test: test_desc, monitor_ch: comm::chan<monitor_msg>) {
391391
task::task().unlinked().future_result(|+r| {
392392
result_future = some(r);
393393
}).spawn(testfn);
394-
let task_result = future::get(option::unwrap(result_future));
394+
let task_result = future::get(&option::unwrap(result_future));
395395
let test_result = calc_result(test, task_result == task::success);
396396
comm::send(monitor_ch, (copy test, test_result));
397397
};

src/rustdoc/markdown_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ fn future_writer_factory(
274274
do task::spawn {
275275
let (writer, future) = future_writer();
276276
comm::send(writer_ch, writer);
277-
let s = future::get(future);
277+
let s = future::get(&future);
278278
comm::send(markdown_ch, (page, s));
279279
}
280280
comm::recv(writer_po)

0 commit comments

Comments
 (0)