]>
Commit | Line | Data |
---|---|---|
74b04a01 XL |
1 | fn main() { |
2 | let string1 = String::from("abcd"); | |
3 | let string2 = "xyz"; | |
4 | ||
5 | let result = longest(string1.as_str(), string2); | |
6 | println!("The longest string is {}", result); | |
7 | } | |
8 | ||
9 | // ANCHOR: here | |
923072b8 | 10 | fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { |
74b04a01 XL |
11 | if x.len() > y.len() { |
12 | x | |
13 | } else { | |
14 | y | |
15 | } | |
16 | } | |
17 | // ANCHOR_END: here |