The real deal y0

  • 0 Posts
  • 8 Comments
Joined 1 year ago
cake
Cake day: July 16th, 2023

help-circle

  • Thats interresting, thanks! Stuff for me to look into!
    I also think halfway through the conversation i might have given the impression i was talking about pointers, while it was not my intention to do so. That said, the readonly/mutable reference thing is very interresting!
    Ill look into what rust does/has that is like the following psuedocode :

    DataBaseUser variable1 = GetDataBaseUser(20);
    userService.Users.Add(variable1);
    variable1 = null; // or free?
    [end of function scope here, reference to heap now in list ]



  • Thanks for the response. Ive heard of rust’s compiler being very smart and checking a ton of stuff. Its good thing it does, but i feel like there are things that can cause this issues rust cant catch. Cant put my finger on it.
    What would rust do if you have a class A create something on the heap, and it passes this variable ( by ref ? ) to class B, which saves the value into a private variable in class B. Class A gets out of scope, and would be cleaned up. What it put on the heap would be cleaned up, but class B still has a reference(?) to the value on the heap, no? How would rust handle such a case?