librustc: Implement the proc type as sugar for ~once fn and proc

notation for closures, and disable the feature gate for `once fn` if
used with the `~` sigil.
This commit is contained in:
Patrick Walton 2013-10-28 15:22:49 -07:00
parent e6650c87a3
commit 7e77bf1769
29 changed files with 250 additions and 70 deletions

View file

@ -0,0 +1,27 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
fn call_it(f: proc(~str) -> ~str) {
println(f(~"Fred"))
}
pub fn main() {
let greeting = ~"Hi ";
do call_it |s| {
greeting + s
}
let greeting = ~"Hello ";
call_it(proc(s) {
greeting + s
});
let greeting = ~"Goodbye ";
call_it(proc(s) greeting + s);
let greeting = ~"How's life, ";
call_it(proc(s: ~str) -> ~str {
greeting + s
});
}

View file

@ -64,14 +64,14 @@ fn test_destroy_actually_kills(force: bool) {
use std::libc::consts::os::extra::{FALSE, PROCESS_QUERY_INFORMATION, STILL_ACTIVE };
unsafe {
let proc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid as DWORD);
if proc.is_null() {
let process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid as DWORD);
if process.is_null() {
return false;
}
// proc will be non-null if the process is alive, or if it died recently
// process will be non-null if the process is alive, or if it died recently
let mut status = 0;
GetExitCodeProcess(proc, &mut status);
CloseHandle(proc);
GetExitCodeProcess(process, &mut status);
CloseHandle(process);
return status == STILL_ACTIVE;
}
}