Skip to content

Commit 8d00603

Browse files
committed
Use less move_it in pipes and future (all but one use)
1 parent 6cf2f89 commit 8d00603

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

src/libcore/future.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,21 @@ fn from_value<A>(+val: A) -> Future<A> {
6464
})
6565
}
6666

67-
macro_rules! move_it (
68-
($x:expr) => { unsafe { let y <- *ptr::addr_of($x); y } }
69-
)
70-
7167
fn from_port<A:send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
72-
#[doc = "
73-
Create a future from a port
74-
75-
The first time that the value is requested the task will block
76-
waiting for the result to be received on the port.
77-
"];
68+
/*!
69+
* Create a future from a port
70+
*
71+
* The first time that the value is requested the task will block
72+
* waiting for the result to be received on the port.
73+
*/
7874

7975
let port = ~mut some(port);
8076
do from_fn |move port| {
8177
let mut port_ = none;
8278
port_ <-> *port;
8379
let port = option::unwrap(port_);
8480
match recv(port) {
85-
future_pipe::completed(data) => move_it!(data)
81+
future_pipe::completed(move data) => data
8682
}
8783
}
8884
}

src/libcore/pipes.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ unsafe fn get_buffer<T: send>(p: *packet_header) -> ~buffer<T> {
325325
transmute((*p).buf_header())
326326
}
327327

328+
// This could probably be done with SharedMutableState to avoid move_it!().
328329
struct buffer_resource<T: send> {
329330
let buffer: ~buffer<T>;
330331
new(+b: ~buffer<T>) {
@@ -962,8 +963,8 @@ impl<T: send> chan<T>: channel<T> {
962963
let mut endp = none;
963964
endp <-> self.endp;
964965
match move streamp::client::try_data(unwrap(endp), x) {
965-
some(next) => {
966-
self.endp = some(move_it!(next));
966+
some(move next) => {
967+
self.endp = some(next);
967968
true
968969
}
969970
none => false
@@ -984,9 +985,9 @@ impl<T: send> port<T>: recv<T> {
984985
let mut endp = none;
985986
endp <-> self.endp;
986987
match move pipes::try_recv(unwrap(endp)) {
987-
some(streamp::data(x, endp)) => {
988-
self.endp = some(move_it!(endp));
989-
some(move_it!(x))
988+
some(streamp::data(move x, move endp)) => {
989+
self.endp = some(endp);
990+
some(x)
990991
}
991992
none => none
992993
}
@@ -1029,12 +1030,8 @@ struct PortSet<T: send> : recv<T> {
10291030
while result == none && ports.len() > 0 {
10301031
let i = wait_many(ports);
10311032
match move ports[i].try_recv() {
1032-
// FIXME (#2329): use this version once move from enum works.
1033-
//some(copy m) => {
1034-
// result = some(move m);
1035-
//}
1036-
some(m) => {
1037-
result = some(move_it!(m));
1033+
some(move m) => {
1034+
result = some(m);
10381035
}
10391036
none => {
10401037
// Remove this port.
@@ -1047,12 +1044,7 @@ struct PortSet<T: send> : recv<T> {
10471044
}
10481045

10491046
fn recv() -> T {
1050-
match move self.try_recv() {
1051-
// FIXME (#2329): use this version once move from enum works.
1052-
//some(copy x) => move x,
1053-
some(x) => move_it!(x),
1054-
none => fail ~"port_set: endpoints closed"
1055-
}
1047+
option::unwrap_expect(self.try_recv(), "port_set: endpoints closed")
10561048
}
10571049

10581050
pure fn peek() -> bool {

0 commit comments

Comments
 (0)