1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-05-20 17:33:31 +02:00

Rust does automatically takes a reference, sometimes (#2718)

fix #2694
This commit is contained in:
Bjørn Jørgensen 2025-04-28 10:08:36 +02:00 committed by GitHub
parent d6fbd215a1
commit 6ef577bcc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -39,8 +39,8 @@ value.
will recognize references as pointers. Later parts of the course will cover
how Rust prevents the memory-safety bugs that come from using raw pointers.
- Rust does not automatically create references for you - the `&` is always
required.
- Explicit referencing with `&` is usually required. However, Rust performs
automatic referencing and dereferencing when invoking methods.
- Rust will auto-dereference in some cases, in particular when invoking methods
(try `r.is_ascii()`). There is no need for an `->` operator like in C++.