chiark / gitweb /
wip
[talk-2019-ghm-rust.git] / dangling.txt
1 fn main() {
2     let reference_to_nothing = dangle();
3 }
4
5 fn dangle() -> &String {
6     let s = String::from("hello");
7     &s
8 }
9
10
11 error[E0106]: missing lifetime specifier
12  --> main.rs:5:16
13   |
14 5 | fn dangle() -> &String {
15   |                ^ expected lifetime parameter
16   |
17   = help: this function's return type contains a borrowed
18     value, but there is no value for it to be borrowed from
19   = help: consider giving it a 'static lifetime