News for hackers. Stuff that matters.
Re:Unreal Rust by spoiler on Monday September 05, 2022 @05:28AM (#32722230)
I would be curious to know more about this case too, fwiw!

Personally, I've only struggled a bit with the borrow checker in a couples of cases: trying to have self/circular references when trying to model OOP, and when fiddling/interacting with some low level async code. Both were unnecessary in my case, and each situation was caused by a lack of understanding.

Re:Unreal Rust by Veliladon on Monday September 05, 2022 @07:29AM (#32723140)
You can put recurring references in a type, you just need to Box it up first.

So you'd have something like:

   enum List<T> {
       Cons(T, Box<List<T>>),
       Nil,
   }
Since the list is now boxed up the borrow checker has a fixed sized object to put on the stack at compile time.
Re:Unreal Rust by pornel on Monday September 05, 2022 @01:46PM (#32727019)
Previous post mentioned self/circular references. You can't do that with a `Box`. You can with `Rc<RefCell<List` or `*mut List`, but those options either have a runtime cost, or aren't borrow-checked.

Lack of self-referential types that are both safe and zero-cost is a legit limitation of Rust.

Re:Unreal Rust by spoiler on Monday September 05, 2022 @11:25AM (#32725331)
Hi! Thanks for taking the time to explain the concept! I'm familiar with these (and others) now, but I was curious to know what others issues the commenter alludes to