From 311f601a280df8d671f6aec8a2037fca66253350 Mon Sep 17 00:00:00 2001 From: Freeman LIU Date: Fri, 2 May 2025 10:34:38 +0800 Subject: [PATCH] Fixed the explanation for life time for return values. --- nostarch/chapter10.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nostarch/chapter10.md b/nostarch/chapter10.md index 146dab4d26..7279a442aa 100644 --- a/nostarch/chapter10.md +++ b/nostarch/chapter10.md @@ -1445,13 +1445,13 @@ This code should compile and produce the result we want when we use it with the `main` function in Listing 10-19. The function signature now tells Rust that for some lifetime `'a`, the function -takes two parameters, both of which are string slices that live at least as -long as lifetime `'a`. The function signature also tells Rust that the string -slice returned from the function will live at least as long as lifetime `'a`. -In practice, it means that the lifetime of the reference returned by the -`longest` function is the same as the smaller of the lifetimes of the values -referred to by the function arguments. These relationships are what we want -Rust to use when analyzing this code. +takes two parameters, both of which are string slices that live at least as long +as lifetime `'a`. The function signature also tells Rust that the string slice +returned from the function will live at most as long as lifetime `'a`. In +practice, it means that the lifetime of the reference returned by the `longest` +function is less than or the same as the smaller of the lifetimes of the values +referred to by the function arguments. These relationships are what we want Rust +to use when analyzing this code. Remember, when we specify the lifetime parameters in this function signature, we’re not changing the lifetimes of any values passed in or returned. Rather,