Fix a few typos in type inference chapter
Also try to test the top example
This commit is contained in:
parent
5334521f8d
commit
7d3823b5a3
|
|
@ -6,14 +6,14 @@ expression.
|
||||||
It is what allows Rust to work with fewer or no type annotations,
|
It is what allows Rust to work with fewer or no type annotations,
|
||||||
making things easier for users:
|
making things easier for users:
|
||||||
|
|
||||||
```rust,ignore
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut things = vec![];
|
let mut things = vec![];
|
||||||
things.push("thing")
|
things.push("thing");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Here, the type of `things` is *inferenced* to be `&str` because that's the value
|
Here, the type of `things` is *inferred* to be `Vec<&str>` because of the value
|
||||||
we push into `things`.
|
we push into `things`.
|
||||||
|
|
||||||
The type inference is based on the standard Hindley-Milner (HM) type inference
|
The type inference is based on the standard Hindley-Milner (HM) type inference
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue