diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-03-01 14:15:15 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-03-02 16:49:31 -0800 |
| commit | a38cbebd8c21f2a9ea97d5a5802cdc34045e9cc1 (patch) | |
| tree | 127ac6ab5d79bb137a7d215f84969bb3a8ce3a28 /src/libstd | |
| parent | 256afb8a1057fdbe7bca2860af1ddb6ef0768d5c (diff) | |
| download | rust-a38cbebd8c21f2a9ea97d5a5802cdc34045e9cc1.tar.gz rust-a38cbebd8c21f2a9ea97d5a5802cdc34045e9cc1.zip | |
libstd: Remove `fn@`, `fn~`, and `fn&` from libstd. rs=defun
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/c_vec.rs | 6 | ||||
| -rw-r--r-- | src/libstd/future.rs | 6 | ||||
| -rw-r--r-- | src/libstd/net_tcp.rs | 18 | ||||
| -rw-r--r-- | src/libstd/par.rs | 27 | ||||
| -rw-r--r-- | src/libstd/test.rs | 16 | ||||
| -rw-r--r-- | src/libstd/uv_global_loop.rs | 5 | ||||
| -rw-r--r-- | src/libstd/uv_iotask.rs | 5 |
7 files changed, 43 insertions, 40 deletions
diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 5af596c1f84..30538a12942 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -53,7 +53,7 @@ pub struct CVec<T> { } struct DtorRes { - dtor: Option<fn@()>, + dtor: Option<@fn()>, } impl Drop for DtorRes { @@ -65,7 +65,7 @@ impl Drop for DtorRes { } } -fn DtorRes(dtor: Option<fn@()>) -> DtorRes { +fn DtorRes(dtor: Option<@fn()>) -> DtorRes { DtorRes { dtor: dtor } @@ -102,7 +102,7 @@ pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> { * * dtor - A function to run when the value is destructed, useful * for freeing the buffer, etc. */ -pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@()) +pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: @fn()) -> CVec<T> { return CVec{ base: base, diff --git a/src/libstd/future.rs b/src/libstd/future.rs index c5775406125..990c37ce807 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -37,13 +37,13 @@ pub struct Future<A> { } // FIXME(#2829) -- futures should not be copyable, because they close -// over fn~'s that have pipes and so forth within! +// over ~fn's that have pipes and so forth within! impl<A> Drop for Future<A> { fn finalize(&self) {} } priv enum FutureState<A> { - Pending(fn~() -> A), + Pending(~fn() -> A), Evaluating, Forced(A) } @@ -125,7 +125,7 @@ pub fn from_fn<A>(f: ~fn() -> A) -> Future<A> { Future {state: Pending(f)} } -pub fn spawn<A:Owned>(blk: fn~() -> A) -> Future<A> { +pub fn spawn<A:Owned>(blk: ~fn() -> A) -> Future<A> { /*! * Create a future from a unique closure. * diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 4266cab0a05..5b116705698 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -625,8 +625,8 @@ pub fn accept(new_conn: TcpNewConnection) */ pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint, iotask: &IoTask, - on_establish_cb: fn~(SharedChan<Option<TcpErrData>>), - new_connect_cb: fn~(TcpNewConnection, + on_establish_cb: ~fn(SharedChan<Option<TcpErrData>>), + new_connect_cb: ~fn(TcpNewConnection, SharedChan<Option<TcpErrData>>)) -> result::Result<(), TcpListenErrData> { do listen_common(host_ip, port, backlog, iotask, @@ -643,11 +643,13 @@ pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint, } } -fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint, - iotask: &IoTask, - on_establish_cb: fn~(SharedChan<Option<TcpErrData>>), - on_connect_cb: fn~(*uv::ll::uv_tcp_t)) - -> result::Result<(), TcpListenErrData> { +fn listen_common(host_ip: ip::IpAddr, + port: uint, + backlog: uint, + iotask: &IoTask, + on_establish_cb: ~fn(SharedChan<Option<TcpErrData>>), + on_connect_cb: ~fn(*uv::ll::uv_tcp_t)) + -> result::Result<(), TcpListenErrData> { unsafe { let (stream_closed_po, stream_closed_ch) = stream::<()>(); let stream_closed_ch = SharedChan(stream_closed_ch); @@ -1197,7 +1199,7 @@ struct TcpListenFcData { server_stream_ptr: *uv::ll::uv_tcp_t, stream_closed_ch: SharedChan<()>, kill_ch: SharedChan<Option<TcpErrData>>, - on_connect_cb: fn~(*uv::ll::uv_tcp_t), + on_connect_cb: ~fn(*uv::ll::uv_tcp_t), iotask: IoTask, ipv6: bool, mut active: bool, diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 0839ce18123..d65921f910c 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -94,24 +94,24 @@ pub fn map<A:Copy + Owned,B:Copy + Owned>( xs: &[A], fn_factory: &fn() -> ~fn(&A) -> B) -> ~[B] { vec::concat(map_slices(xs, || { let f = fn_factory(); - fn~(_base: uint, slice : &[A]) -> ~[B] { - vec::map(slice, |x| f(x)) - } + let result: ~fn(uint, &[A]) -> ~[B] = + |_, slice| vec::map(slice, |x| f(x)); + result })) } /// A parallel version of mapi. pub fn mapi<A:Copy + Owned,B:Copy + Owned>( - xs: &[A], - fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] -{ + xs: &[A], + fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] { let slices = map_slices(xs, || { let f = fn_factory(); - fn~(base: uint, slice : &[A]) -> ~[B] { + let result: ~fn(uint, &[A]) -> ~[B] = |base, slice| { vec::mapi(slice, |i, x| { f(i + base, x) }) - } + }; + result }); let r = vec::concat(slices); log(info, (r.len(), xs.len())); @@ -126,11 +126,12 @@ pub fn alli<A:Copy + Owned>( { do vec::all(map_slices(xs, || { let f = fn_factory(); - fn~(base: uint, slice : &[A]) -> bool { + let result: ~fn(uint, &[A]) -> bool = |base, slice| { vec::alli(slice, |i, x| { f(i + base, x) }) - } + }; + result })) |x| { *x } } @@ -140,8 +141,8 @@ pub fn any<A:Copy + Owned>( fn_factory: &fn() -> ~fn(&A) -> bool) -> bool { do vec::any(map_slices(xs, || { let f = fn_factory(); - fn~(_base : uint, slice: &[A]) -> bool { - vec::any(slice, |x| f(x)) - } + let result: ~fn(uint, &[A]) -> bool = + |_, slice| vec::any(slice, |x| f(x)); + result })) |x| { *x } } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 3ebebe59d94..4ffa9b01d2b 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -409,7 +409,7 @@ type MonitorMsg = (TestDesc, TestResult); fn run_tests(opts: &TestOpts, tests: ~[TestDescAndFn], - callback: fn@(e: TestEvent)) { + callback: @fn(e: TestEvent)) { let mut filtered_tests = filter_tests(opts, tests); let filtered_descs = filtered_tests.map(|t| t.desc); @@ -537,7 +537,7 @@ pub fn filter_tests( struct TestFuture { test: TestDesc, - wait: fn@() -> TestResult, + wait: @fn() -> TestResult, } pub fn run_test(force_ignore: bool, @@ -782,7 +782,7 @@ mod tests { ignore: true, should_fail: false }, - testfn: DynTestFn(fn~() { f()}), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -800,7 +800,7 @@ mod tests { ignore: true, should_fail: false }, - testfn: DynTestFn(fn~() { f()}), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -819,7 +819,7 @@ mod tests { ignore: false, should_fail: true }, - testfn: DynTestFn(fn~() { f() }), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -837,7 +837,7 @@ mod tests { ignore: false, should_fail: true }, - testfn: DynTestFn(fn~() { f() }), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -890,7 +890,7 @@ mod tests { ignore: true, should_fail: false, }, - testfn: DynTestFn(fn~() { }), + testfn: DynTestFn(|| {}), }, TestDescAndFn { desc: TestDesc { @@ -898,7 +898,7 @@ mod tests { ignore: false, should_fail: false }, - testfn: DynTestFn(fn~() { }), + testfn: DynTestFn(|| {}), }, ]; let filtered = filter_tests(&opts, tests); diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 1898ef77320..daf90f345e0 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -97,7 +97,7 @@ fn get_monitor_task_gl() -> IoTask { fn spawn_loop() -> IoTask { let builder = do task().add_wrapper |task_body| { - fn~() { + let result: ~fn() = || { // The I/O loop task also needs to be weak so it doesn't keep // the runtime alive unsafe { @@ -112,7 +112,8 @@ fn spawn_loop() -> IoTask { debug!("global libuv task is leaving weakened state"); } } - } + }; + result }; let builder = builder.unlinked(); spawn_iotask(builder) diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 14726a0854d..6179b10f3c3 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -76,8 +76,7 @@ pub fn spawn_iotask(task: task::TaskBuilder) -> IoTask { * module. It is not safe to send the `loop_ptr` param to this callback out * via ports/chans. */ -pub unsafe fn interact(iotask: &IoTask, - cb: fn~(*c_void)) { +pub unsafe fn interact(iotask: &IoTask, cb: ~fn(*c_void)) { send_msg(iotask, Interaction(cb)); } @@ -98,7 +97,7 @@ pub fn exit(iotask: &IoTask) { // INTERNAL API enum IoTaskMsg { - Interaction (fn~(*libc::c_void)), + Interaction(~fn(*libc::c_void)), TeardownLoop } |
