|
Jsor posted:It turns out the answer was "use Rc<RefCell<blah>>". That was a fun, if somewhat frustrating, adventure. I eventually went back to the recursive code because it turns out the iterative code had almost no benefit -- the stack overflows at pretty much the same point whether I'm using a homebrewed stack or a recursive one, which I definitely didn't expect! Yeah, the shittiest part of learning Rust is hammering nails into your dick trying to write data structure stuff. It's trivial in other languages, but writing them in (safe) Rust requires a decent understanding of its complex memory model, so it's a pretty bad place to start off. Rc and RefCell are usually enough to cover the gaps the borrow checker can't handle if you're cool with the overhead associated with them. If you're not, or you have a situation that's difficult to solve in safe Rust (doubly-linked list is one), don't be afraid to drop to unsafe{} . The standard library (which is written in Rust) uses it extensively.
|
# ¿ Jul 31, 2015 09:20 |
|
|
# ¿ Apr 29, 2024 19:55 |
|
Jsor posted:Rust's runtime debugging really needs some work, though. If you have an erroneous `unwrap` you helpfully get the line number of the source code for Option it calls panic! on rather than the actual part of your code. This would be fine if RUST_BACKTRACE wasn't utterly useless on non-Linux systems, on my Windows machine it helpfully prints: Yeah Windows debugger stack traces were working fine a little while back but ever since I upgraded to 1.4 beta and on it's been broken. Bit of a pain, unwrap isn't ideal and all but it's great for testing/prototyping. Tooling is definitely something Rust is lacking in at the moment. One of the Mozilla Rust guys lists his predictions for Rust in 2016. Better tooling is high up on that. Personally Visual Rust fully fleshed out would be a breaking point for me, decent IDE support and VS's debugger would be a multiplier on my productivity for sure.
|
# ¿ Jan 7, 2016 14:42 |
|
After a bit of looking around, there's a pretty simple workaround to this. Run it in gdb, enter 'break rust_panic', and when it hits the breakpoint 'bt' for a stacktrace. Apparently rust_panic is specifically there so you can place breakpoints on panics, which is pretty neat.
|
# ¿ Jan 11, 2016 12:52 |