From f6bd152fa77964b706b5cb9e3cc90915354e0cda Mon Sep 17 00:00:00 2001 From: Raphael <4246780+reitzig@users.noreply.github.com> Date: Tue, 18 Mar 2025 11:37:14 +0100 Subject: [PATCH] Ch. 10.3: clarify language detail The former phrasing seemed to suggest that we _must not_ annotate types _unless_ there are multiple possibilities. In fact, we are allowed to add redundant annotations. Cases where no annotation is needed _despite_ multiple possible types -- e.g. `let n = 8` -- are, presumably, intentionally left out here, so not touching that. --- src/ch10-03-lifetime-syntax.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ch10-03-lifetime-syntax.md b/src/ch10-03-lifetime-syntax.md index ddabaee7b..6b369f1a5 100644 --- a/src/ch10-03-lifetime-syntax.md +++ b/src/ch10-03-lifetime-syntax.md @@ -8,8 +8,8 @@ One detail we didn’t discuss in the [“References and Borrowing”][references-and-borrowing] section in Chapter 4 is that every reference in Rust has a _lifetime_, which is the scope for which that reference is valid. Most of the time, lifetimes are implicit and inferred, -just like most of the time, types are inferred. We must annotate types only -when multiple types are possible. In a similar way, we must annotate lifetimes +just like most of the time, types are inferred. We only have to annotate types +when multiple types are possible. In a similar way, we have to annotate lifetimes when the lifetimes of references could be related in a few different ways. Rust requires us to annotate the relationships using generic lifetime parameters to ensure the actual references used at runtime will definitely be valid.