Make 'lambda(...) -> ...' parse as a type
This commit is contained in:
parent
4e9b8a28f7
commit
eaf9e05611
2 changed files with 10 additions and 26 deletions
|
@ -25,13 +25,10 @@ expected to return.
|
|||
|
||||
## Closures
|
||||
|
||||
FIXME Either move entirely to fn~/fn@ nomenclature, or fix compiler to
|
||||
accept lambda as a type
|
||||
|
||||
Normal Rust functions (declared with `fn`) do not close over their
|
||||
environment. A `lambda` expression can be used to create a closure.
|
||||
|
||||
fn make_plus_function(x: int) -> fn@(int) -> int {
|
||||
fn make_plus_function(x: int) -> lambda(int) -> int {
|
||||
lambda(y: int) -> int { x + y }
|
||||
}
|
||||
let plus_two = make_plus_function(2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue