@@ -478,9 +478,7 @@ a type error. Read about [single-variant enums](#single_variant_enum)
478
478
further on if you need to create a type name that's not just a
479
479
synonym.
480
480
481
- ## Literals
482
-
483
- ### Numeric literals
481
+ ## Numeric literals
484
482
485
483
Integers can be written in decimal (` 144 ` ), hexadecimal (` 0x90 ` ), and
486
484
binary (` 0b10010000 ` ) base.
@@ -539,7 +537,7 @@ and `f64` can be used to create literals of a specific type. The
539
537
suffix `f` can be used to write `float` literals without a dot or
540
538
exponent: `3f`.
541
539
542
- ### Other literals
540
+ ## Other literals
543
541
544
542
The nil literal is written just like the type: `()`. The keywords
545
543
`true` and `false` produce the boolean literals.
@@ -1224,8 +1222,8 @@ Because of this Rust also introduces a global "exchange heap". Objects
1224
1222
allocated here have _ownership semantics_, meaning that there is only
1225
1223
a single variable that refers to them. For this reason they are
1226
1224
refered to as _unique boxes_. All tasks may allocate objects on this
1227
- heap, then _move_ those allocations to other tasks, avoiding expensive
1228
- copies.
1225
+ heap, then transfer ownership of those allocations to other tasks,
1226
+ avoiding expensive copies.
1229
1227
1230
1228
## What to be aware of
1231
1229
@@ -1531,10 +1529,9 @@ if favorite_crayon_name.len() > 5 {
1531
1529
1532
1530
# Closures
1533
1531
1534
- Named functions, like those in the previous section, may not refer
1535
- to local variables decalared outside the function - they do not
1536
- close over their environment. For example you couldn't write the
1537
- following:
1532
+ Named functions, like those we've seen so far, may not refer to local
1533
+ variables decalared outside the function - they do not "close over
1534
+ their environment". For example you couldn't write the following:
1538
1535
1539
1536
~~~~ {.ignore}
1540
1537
let foo = 10;
@@ -1557,10 +1554,11 @@ let closure = |arg| println(#fmt("captured_var=%d, arg=%d", captured_var, arg));
1557
1554
call_closure_with_ten(closure);
1558
1555
~~~~
1559
1556
1560
- The types of the arguments are generally omitted, as is the return
1561
- type, because the compiler can almost always infer them. In the rare
1562
- case where the compiler needs assistance though, the arguments and
1563
- return types may be annotated.
1557
+ Closures begin with the argument list between bars and are followed by
1558
+ a single expression. The types of the arguments are generally omitted,
1559
+ as is the return type, because the compiler can almost always infer
1560
+ them. In the rare case where the compiler needs assistance though, the
1561
+ arguments and return types may be annotated.
1564
1562
1565
1563
~~~~
1566
1564
# type mygoodness = fn(str) -> str; type what_the = int;
@@ -1584,7 +1582,7 @@ position and cannot be stored in structures nor returned from
1584
1582
functions. Despite the limitations stack closures are used
1585
1583
pervasively in Rust code.
1586
1584
1587
- ## Boxed closures
1585
+ ## Shared closures
1588
1586
1589
1587
When you need to store a closure in a data structure, a stack closure
1590
1588
will not do, since the compiler will refuse to let you store it. For
0 commit comments