@@ -342,8 +342,8 @@ let foo_ptr_2 = if want_i32 {
342
342
};
343
343
```
344
344
345
- All function items implement [ Fn ] , [ FnMut] , [ FnOnce] , [ Copy] , [ Clone ] , [ Send ] ,
346
- and [ Sync] .
345
+ All function items implement [ ` Fn ` ] , [ ` FnMut ` ] , [ ` FnOnce ` ] , [ ` Copy ` ] ,
346
+ [ ` Clone] ` , [ ` Send ` ] , and [ ` Sync ` ] .
347
347
348
348
## Function pointer types
349
349
@@ -450,20 +450,20 @@ borrowed to iterate over, the code would not compile.
450
450
451
451
### Call traits and coercions
452
452
453
- Closure types all implement ` [ FnOnce] ` , indicating that they can be called once
453
+ Closure types all implement [ ` FnOnce ` ] , indicating that they can be called once
454
454
by consuming ownership of the closure. Additionally, some closures implement
455
455
more specific call traits:
456
456
457
457
* A closure which does not move out of any captured variables implements
458
- ` [ FnMut] ` , indicating that it can be called by mutable reference.
458
+ [ ` FnMut ` ] , indicating that it can be called by mutable reference.
459
459
460
460
* A closure which does not mutate or move out of any captured variables
461
- implements ` [Fn] ` , indicating that it can be called by shared reference.
461
+ implements [ ` Fn ` ] , indicating that it can be called by shared reference.
462
462
463
- > Note: ` move ` closures may still implement ` [Fn] ` or ` [ FnMut] ` , even though
463
+ > Note: ` move ` closures may still implement [ ` Fn ` ] or [ ` FnMut ` ] , even though
464
464
> they capture variables by move. This is because the traits implemented by a
465
- > closure type are determined by what the closure does with captured values, not
466
- > how it captures them.
465
+ > closure type are determined by what the closure does with captured values,
466
+ > not how it captures them.
467
467
468
468
* Non-capturing closures* are closures that don't capture anything from their
469
469
environment. They can be coerced to function pointers (` fn ` ) with the matching
@@ -481,28 +481,28 @@ x = bo(5,7);
481
481
482
482
### Other traits
483
483
484
- All closure types implement ` [ Sized] ` . Additionally, closure types implement the
484
+ All closure types implement [ ` Sized ` ] . Additionally, closure types implement the
485
485
following traits if allowed to do so by the types of the captures it stores:
486
486
487
- * ` [ Clone] `
488
- * ` [ Copy] `
489
- * ` [ Sync] `
490
- * ` [ Send] `
487
+ * [ ` Clone ` ]
488
+ * [ ` Copy ` ]
489
+ * [ ` Sync ` ]
490
+ * [ ` Send ` ]
491
491
492
- The rules for ` [ Send] ` and ` [ Sync] ` match those for normal struct types, while
493
- ` [ Clone] ` and ` [ Copy] ` behave as if [ derived] [ derive ] . For ` [ Clone] ` , the order
492
+ The rules for [ ` Send ` ] and [ ` Sync ` ] match those for normal struct types, while
493
+ [ ` Clone ` ] and [ ` Copy ` ] behave as if [ derived] [ derive ] . For [ ` Clone ` ] , the order
494
494
of cloning of the captured variables is left unspecified.
495
495
496
496
Because captures are often by reference, the following general rules arise:
497
497
498
- * A closure is ` [ Sync] ` if all variables captured by mutable reference, copy, or
499
- move are ` [ Sync] ` .
500
- * A closure is ` [ Send] ` if all variables captured by shared reference are
501
- ` [ Sync] ` , and all values captured by mutable reference, copy, or move are
502
- ` [ Send] ` .
503
- * A closure is ` [ Clone] ` or ` [ Copy] ` if it does not capture any values by
504
- mutable reference, and if all values it captures by copy or move are ` [Clone] `
505
- or ` [ Copy] ` , respectively.
498
+ * A closure is [ ` Sync ` ] if all variables captured by mutable reference, copy,
499
+ or move are [ ` Sync ` ] .
500
+ * A closure is [ ` Send ` ] if all variables captured by shared reference are
501
+ [ ` Sync ` ] , and all values captured by mutable reference, copy, or move are
502
+ [ ` Send ` ] .
503
+ * A closure is [ ` Clone ` ] or [ ` Copy ` ] if it does not capture any values by
504
+ mutable reference, and if all values it captures by copy or move are
505
+ [ ` Clone ` ] or [ ` Copy ` ] , respectively.
506
506
507
507
## Trait objects
508
508
@@ -643,13 +643,14 @@ impl Printable for String {
643
643
644
644
> Note: The notation ` &self ` is a shorthand for ` self: &Self ` .
645
645
646
- [ Fn ] : ../std/ops/trait.Fn.html
647
- [ FnMut ] : ../std/ops/trait.FnMut.html
648
- [ FnOnce ] : ../std/ops/trait.FnOnce.html
649
- [ Copy ] : special-types-and-traits.html#copy
650
- [ Clone ] : special-types-and-traits.html#clone
651
- [ Send ] : special-types-and-traits.html#send
652
- [ Sync ] : special-types-and-traits.html#sync
646
+ [ `Fn` ] : ../std/ops/trait.Fn.html
647
+ [ `FnMut` ] : ../std/ops/trait.FnMut.html
648
+ [ `FnOnce` ] : ../std/ops/trait.FnOnce.html
649
+ [ `Copy` ] : special-types-and-traits.html#copy
650
+ [ `Clone` ] : special-types-and-traits.html#clone
651
+ [ `Send` ] : special-types-and-traits.html#send
652
+ [ `Sync` ] : special-types-and-traits.html#sync
653
+ [ `Sized` ] : special-types-and-traits.html#sized
653
654
[ derive ] : attributes.html#derive
654
655
[ `Vec<T>` ] : ../std/vec/struct.Vec.html
655
656
[ dynamically sized type ] : dynamically-sized-types.html
0 commit comments