From 6ef577bcc7970b6402982a6a1d63a29b21584cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20J=C3=B8rgensen?= Date: Mon, 28 Apr 2025 10:08:36 +0200 Subject: [PATCH] Rust does automatically takes a reference, sometimes (#2718) fix #2694 --- src/references/shared.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/references/shared.md b/src/references/shared.md index 63fc79f0..57804056 100644 --- a/src/references/shared.md +++ b/src/references/shared.md @@ -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++.