From ae27ad2db254e0a324aca63fd7a9038bb59ae5bc Mon Sep 17 00:00:00 2001 From: Fabian Schmidt Date: Tue, 23 Jan 2024 11:00:39 +0100 Subject: [PATCH] Example with lifetimes specified --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 2c19b59..505ce72 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,11 @@ fn main() { println!("The longest string is {result}"); } -fn longest(a: &str, b: &str) -> &str { +fn longest<'a, 'b, 'out>(a: &'a str, b: &'b str) -> &'out str +where + 'a: 'out, + 'b: 'out, +{ if a.len() > b.len() { a } else {