-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Description
In the section “Lifetime Annotations in Function Signatures” of chapter 10, there is the following description of listing 10-22:
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
if x.len() > y.len() {
x
} else {
y
}
}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. [Emphasis added]
Shouldn’t the last sentence read “the string slice returned from the function will live at most as long as lifetime 'a”?
Metadata
Metadata
Assignees
Labels
No labels