From db7c467d2a38da13ad1988cdb4f4138d2a11751b Mon Sep 17 00:00:00 2001 From: Adam <134429563+RustoMCSpit@users.noreply.github.com> Date: Thu, 19 Mar 2026 20:57:51 +0000 Subject: [PATCH] Update documentation on string slices in Rust Clarify the explanation of string slices and references in Rust. --- src/ch04-03-slices.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ch04-03-slices.md b/src/ch04-03-slices.md index 7f145baf1d..21965f1505 100644 --- a/src/ch04-03-slices.md +++ b/src/ch04-03-slices.md @@ -178,7 +178,9 @@ let slice = &s[..]; > multibyte character, your program will exit with an error. With all this information in mind, let’s rewrite `first_word` to return a -slice. The type that signifies “string slice” is written as `&str`: +slice. Note for the below code that `*` usually dereferences a reference in expressions, +while `&` in a pattern matches a reference and automatically unwraps its value. +The type that signifies “string slice” is written as `&str`: