Skip to content

Commit

Permalink
finish lifetimes2
Browse files Browse the repository at this point in the history
  • Loading branch information
cyz-ing committed Jan 31, 2025
1 parent b472d7b commit 46ea65b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions exercises/lifetimes/lifetimes2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {

fn main() {
let string1 = String::from("long string is long");
let result;
{
let string2 = String::from("xyz");
result = longest(string1.as_str(), string2.as_str());
}
let string2 = String::from("xyz");
let result = longest(string1.as_str(), string2.as_str());
println!("The longest string is '{}'", result);
}

0 comments on commit 46ea65b

Please sign in to comment.