1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-01-09 09:11:50 +02:00

Update the Speaker Notes of the type-inference.md (#214)

* Update the Speaker Notes of the type-inference.md

I think this is one of the critical moments in understanding Rust. This behavior is different from many static and dynamic programming languages.

* Fix typo

Co-authored-by: Andrew Walbran <qwandor@google.com>
This commit is contained in:
Igor Petruk 2023-01-23 11:05:46 +00:00 committed by GitHub
parent ec7125da2e
commit 8c58253217
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,10 @@ fn main() {
<details>
This slide demonstrates how the Rust compiler infers types based on constraints given by variable declarations and usages.
It is very important to emphasize that variables declared like this are not of some sort of dynamic "any type" that can
hold any data. The machine code generated by such declaration is identical to the explicit declaration of a type.
The compiler does the job for us and helps us to write a more concise code.
The following code tells the compiler to copy into a certain generic container without the code ever explicitly specifying the contained type, using `_` as a placeholder: