diff options
Diffstat (limited to 'rust/theBook/chapter-4-understanding-ownership/emp2.rs')
-rw-r--r-- | rust/theBook/chapter-4-understanding-ownership/emp2.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/rust/theBook/chapter-4-understanding-ownership/emp2.rs b/rust/theBook/chapter-4-understanding-ownership/emp2.rs new file mode 100644 index 0000000..02a24b0 --- /dev/null +++ b/rust/theBook/chapter-4-understanding-ownership/emp2.rs @@ -0,0 +1,11 @@ +fn main() { + let str = dangle(); + + println!("{str}"); +} + +fn dangle() -> &String { + let s = String::from("Hello"); + + &s +} |