From d15314527b5bea4d8d85bd80a389d097910b07ac Mon Sep 17 00:00:00 2001 From: IP1llar Date: Thu, 8 Feb 2024 19:48:21 +0000 Subject: [PATCH] Update lifetime-elision.md (#1795) In the details section, it is suggested to adjust the signature of the nearest function to "lie" about the lifetimes returned to: fn nearest<'a, 'q'>(points: &'a [Point], query: &'q Point) -> Option<&'q Point> { to demonstrate the compiler checks lifetimes for validity. However, the syntax for 'q is incorrect and it should instead be fn nearest<'a, 'q>(points: &'a [Point], query: &'q Point) -> Option<&'q Point> { --- src/slices-and-lifetimes/lifetime-elision.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slices-and-lifetimes/lifetime-elision.md b/src/slices-and-lifetimes/lifetime-elision.md index 9a55ee3e2bd1..58c9fb32e83a 100644 --- a/src/slices-and-lifetimes/lifetime-elision.md +++ b/src/slices-and-lifetimes/lifetime-elision.md @@ -61,7 +61,7 @@ references in its arguments that requires explicit annotation. Try adjusting the signature to "lie" about the lifetimes returned: ```rust,ignore -fn nearest<'a, 'q'>(points: &'a [Point], query: &'q Point) -> Option<&'q Point> { +fn nearest<'a, 'q>(points: &'a [Point], query: &'q Point) -> Option<&'q Point> { ``` This won't compile, demonstrating that the annotations are checked for validity