libstd: Remove fn@
, fn~
, and fn&
from libstd. rs=defun
This commit is contained in:
parent
256afb8a10
commit
a38cbebd8c
@ -53,7 +53,7 @@ pub struct CVec<T> {
|
||||
}
|
||||
|
||||
struct DtorRes {
|
||||
dtor: Option<fn@()>,
|
||||
dtor: Option<@fn()>,
|
||||
}
|
||||
|
||||
impl Drop for DtorRes {
|
||||
@ -65,7 +65,7 @@ fn finalize(&self) {
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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,
|
||||
|
@ -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 }
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ enum TestEvent {
|
||||
|
||||
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 @@ fn filter(test: TestDescAndFn) -> Option<TestDescAndFn> {
|
||||
|
||||
struct TestFuture {
|
||||
test: TestDesc,
|
||||
wait: fn@() -> TestResult,
|
||||
wait: @fn() -> TestResult,
|
||||
}
|
||||
|
||||
pub fn run_test(force_ignore: bool,
|
||||
@ -782,7 +782,7 @@ pub fn do_not_run_ignored_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 @@ fn f() { }
|
||||
ignore: true,
|
||||
should_fail: false
|
||||
},
|
||||
testfn: DynTestFn(fn~() { f()}),
|
||||
testfn: DynTestFn(|| f()),
|
||||
};
|
||||
let (p, ch) = stream();
|
||||
let ch = SharedChan(ch);
|
||||
@ -819,7 +819,7 @@ pub fn test_should_fail() {
|
||||
ignore: false,
|
||||
should_fail: true
|
||||
},
|
||||
testfn: DynTestFn(fn~() { f() }),
|
||||
testfn: DynTestFn(|| f()),
|
||||
};
|
||||
let (p, ch) = stream();
|
||||
let ch = SharedChan(ch);
|
||||
@ -837,7 +837,7 @@ fn f() { }
|
||||
ignore: false,
|
||||
should_fail: true
|
||||
},
|
||||
testfn: DynTestFn(fn~() { f() }),
|
||||
testfn: DynTestFn(|| f()),
|
||||
};
|
||||
let (p, ch) = stream();
|
||||
let ch = SharedChan(ch);
|
||||
@ -890,7 +890,7 @@ fn dummy() {}
|
||||
ignore: true,
|
||||
should_fail: false,
|
||||
},
|
||||
testfn: DynTestFn(fn~() { }),
|
||||
testfn: DynTestFn(|| {}),
|
||||
},
|
||||
TestDescAndFn {
|
||||
desc: TestDesc {
|
||||
@ -898,7 +898,7 @@ fn dummy() {}
|
||||
ignore: false,
|
||||
should_fail: false
|
||||
},
|
||||
testfn: DynTestFn(fn~() { }),
|
||||
testfn: DynTestFn(|| {}),
|
||||
},
|
||||
];
|
||||
let filtered = filter_tests(&opts, tests);
|
||||
|
@ -97,7 +97,7 @@ fn key(_: GlobalIoTask) { }
|
||||
|
||||
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)
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user