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:
parent
e6650c87a3
commit
7e77bf1769
29 changed files with 250 additions and 70 deletions
27
src/test/run-pass/closure-reform.rs
Normal file
27
src/test/run-pass/closure-reform.rs
Normal 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
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue