News for hackers. Stuff that matters.
Re:Was Rust Worth It? by estebank on Wednesday October 25, 2023 @08:38PM (#38020220)
That doesn't really work. All unsafe lets you do is dereference pointers or call unsafe functions. That's not gonna speed your development up during prototyping.

You can instead wrap everything in Arc<Mutex<T>> and .clone() liberally, though.

Re:Was Rust Worth It? by cchance on Wednesday October 25, 2023 @09:49PM (#38020743)
Always find it funny that people think unsafe {} means that rust ignores everything in the block, it just enables 4-5 additional abilities that are well documented, it's still doing most of its safety checks.
Re:Was Rust Worth It? by trealira on Wednesday October 25, 2023 @10:30PM (#38021005)
It will work if you only use raw pointers everywhere, like it's C. Don't use slices or strings; just pass a pointer to the first element of an array, and either pass its length separately or provide a sentinel value (like C's null terminated strings). Navigate balanced search trees using aliasing, raw, mutable pointers. Etc. This person compares the translation of C to Rust, literally versus idiomatically: https://cliffle.com/p/dangerust/

There will probably be weird behavior, though, because Rust optimizes based on assumptions about boxes and references. For example, if you have 3 raw pointers to some object live at once, and you give some library function a mutable reference made from one of those pointers, the compiler will optimize assuming it has exclusive access to that object, and it may make incorrect assumptions.

Re:Was Rust Worth It? by Buttons840 on Thursday October 26, 2023 @01:01AM (#38021781)
> All unsafe lets you do is dereference pointers or call unsafe functions.

And all those let you do is drop lifetimes and wave goodbye to the borrow checker. You just have to be explicit about it.

(What I mean is, the borrow checker checks borrows, it checks references. In unsafe you can make a reference forget what it's referring to. Just change &'a T to &'static T, and then the borrow checker is doing nothing.)