Skip to content

Commit d153145

Browse files
authored
Update lifetime-elision.md (google#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> {
1 parent 6fcb591 commit d153145

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/slices-and-lifetimes/lifetime-elision.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ references in its arguments that requires explicit annotation.
6161
Try adjusting the signature to "lie" about the lifetimes returned:
6262

6363
```rust,ignore
64-
fn nearest<'a, 'q'>(points: &'a [Point], query: &'q Point) -> Option<&'q Point> {
64+
fn nearest<'a, 'q>(points: &'a [Point], query: &'q Point) -> Option<&'q Point> {
6565
```
6666

6767
This won't compile, demonstrating that the annotations are checked for validity

0 commit comments

Comments
 (0)