News for hackers. Stuff that matters.
Re:Show HN: How to program in Rust as if it was old school C... by sph on Tuesday December 20, 2022 @02:04PM (#34070685)
Option<Rc<RefCell<_>>> is not the same thing as a pointer, as the semantics are different, and it uses much more memory than an actual pointer.

Rust has pointers. If you want to program like old school C++, wrap everything in unsafe and use all the pointers you want.

Re:Show HN: How to program in Rust as if it was old school C... by scotty79 on Tuesday December 20, 2022 @03:15PM (#34071846)
I don't want unsafe. I just want it to be out of my hair. RefCell is perfectly safe.
Re:Show HN: How to program in Rust as if it was old school C... by zamalek on Tuesday December 20, 2022 @09:18PM (#34075911)
> wrap everything in unsafe

You are expected to follow Rust's memory model in unsafe blocks. Treating unsafe Rust like C is much more dangerous than just using C.

Re:Show HN: How to program in Rust as if it was old school C... by SpaghettiCthulu on Wednesday December 21, 2022 @11:11AM (#34082540)
Assuming you're talking about the aliasing rules, my understanding is that that only applies if you are mixing pointers with references. If you just use `pointer::read` `pointer::write` the aliasing rules don't apply (doesn't mean it's safe, but it won't immediately be undefined behaviour to write to a mutable pointer while another mutable pointer exists, as it would be if you aliased a mutable reference).