News for hackers. Stuff that matters.
Re:Effective Rust by duped on Thursday June 15, 2023 @11:47AM (#36342207)
I write Rust professionally.

If you're using Rc you probably mean Arc. And most of the time that you mean Arc you mean Box.

If you're using RefCell you probably have a bad data model. The use case is interior mutability. This turns out to not be that useful in practice if you designed your DS well. Occasionally you need it in the design of some internals, but it's rare (and rare to expose)

If you're fighting the borrow checker you're not writing idiomatic Rust.

> I mean how much of an overhead if RC comparing to the real borrow checker coming from Java or JS world?

Negligible, but the real question is "why do you need RC in the first place?"

Re:Effective Rust by ramranch on Thursday June 15, 2023 @02:24PM (#36344583)
There are certainly areas where idiomatic Rust needs to fight against the borrow checker. If that wasn't the case, things like `ouroborous` and `pin_project` wouldn't be as widely used as they are.
Re:Effective Rust by duped on Thursday June 15, 2023 @03:40PM (#36345439)
Day to day rust users shouldn't care too much about pin_project since the big use case for pin is handrolled futures and executors. Most folks just use adaptors from the futures crate and one of a handful of executors in the ecosystem.

I've never actually heard of that other crate. It looks like most of its downloads come from its direct/indirect dependents like glium. I'd say if you're writing self referential data structures you're not writing idiomatic Rust.

Re:Effective Rust by tmpfs on Thursday June 15, 2023 @07:48PM (#36348721)
Got to disagree here, a typical use case based on my experience is a parser holding a &str as well as an AST that does zero-copy references into the string.