From 4c194893681ccab9a223ea47b166f70fed3e0e69 Mon Sep 17 00:00:00 2001 From: Morris Li Date: Wed, 30 Jun 2021 17:14:17 +0800 Subject: [PATCH] Update ch04-03-slices.md Add Deref Coercions annotations --- src/ch04-03-slices.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ch04-03-slices.md b/src/ch04-03-slices.md index 80f4a47b5..203cd3d65 100644 --- a/src/ch04-03-slices.md +++ b/src/ch04-03-slices.md @@ -256,8 +256,10 @@ and `&str` values. a string slice for the type of the `s` parameter If we have a string slice, we can pass that directly. If we have a `String`, we -can pass a slice of the entire `String`. Defining a function to take a string -slice instead of a reference to a `String` makes our API more general and useful +can pass a slice of the entire `String`. We can also pass the reference of +`String`, thanks to [Deref Coercions][deref-coercions], a feature +we will cover later in Chapter 15. Defining a function to take a string slice +instead of a reference to a `String` makes our API more general and useful without losing any functionality: Filename: src/main.rs @@ -304,3 +306,4 @@ these concepts further throughout the rest of the book. Let’s move on to Chapter 5 and look at grouping pieces of data together in a `struct`. [strings]: ch08-02-strings.html#storing-utf-8-encoded-text-with-strings +[deref-coercions]: ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods