0

Seemingly a simple question.

If we define a string and take a reference to it immediately. Since it doesn't have an owner, how does it know when to drop?

{
    let not_an_owner: &String = &String::from("Hello There");
}

Does the object know about its scope? I thought all variables had to have an owner for them to know when it goes out of scope to trigger the drop.

Iggy
  • 4,767
  • 5
  • 23
  • 34

0 Answers0