We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 003ec56 commit 4ca4f51Copy full SHA for 4ca4f51
rustlang_book/lifetimes/src/main.rs
@@ -1,9 +1,20 @@
1
+pub struct ImportantExcerpt<'a> {
2
+ part: &'a str,
3
+}
4
+
5
fn main() {
6
let string1 = String::from("abcd");
7
let string2 = "xyz";
8
9
let result = longest(string1.as_str(), string2);
10
println!("The longest string is {}", result);
11
12
+ let novel = String::from("Once upon a time there existed a crab. He was called a rustacean...");
13
+ let first_sentence = novel.split('.').next().expect("Could not find a .");
14
+ let i = ImportantExcerpt {
15
+ part : first_sentence,
16
+ };
17
+ println!("The first sentence is: {}" , i.part);
18
}
19
20
fn longest<'a>(string1: &'a str, string2: &'a str) -> &'a str {
0 commit comments