File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 2
2
refs/heads/master: b5ba2f5517b1f90d07969ca3facdf5132e42436c
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 749ff5e76a0d08837964e44c66654679a3a88bb8
5
- refs/heads/try: ee1cbb9c71bfab8500dfabedb35ba63dd1e5b7ff
5
+ refs/heads/try: e2357cf41b69c6db57bbf53c63f59376576c72ae
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
Original file line number Diff line number Diff line change @@ -659,14 +659,12 @@ error: mismatched types: expected `int` but found `()` (expected int but found (
659
659
```
660
660
661
661
We expected an integer, but we got ` () ` . ` () ` is pronounced 'unit', and is a
662
- special type in Rust's type system. ` () ` is different than ` null ` in other
663
- languages, because ` () ` is distinct from other types. For example, in C, ` null `
664
- is a valid value for a variable of type ` int ` . In Rust, ` () ` is _ not_ a valid
665
- value for a variable of type ` int ` . It's only a valid value for variables of
666
- the type ` () ` , which aren't very useful. Remember how we said statements don't
667
- return a value? Well, that's the purpose of unit in this case. The semicolon
668
- turns any expression into a statement by throwing away its value and returning
669
- unit instead.
662
+ special type in Rust's type system. In Rust, ` () ` is _ not_ a valid value for a
663
+ variable of type ` int ` . It's only a valid value for variables of the type ` () ` ,
664
+ which aren't very useful. Remember how we said statements don't return a value?
665
+ Well, that's the purpose of unit in this case. The semicolon turns any
666
+ expression into a statement by throwing away its value and returning unit
667
+ instead.
670
668
671
669
There's one more time in which you won't see a semicolon at the end of a line
672
670
of Rust code. For that, we'll need our next concept: functions.
You can’t perform that action at this time.
0 commit comments