Ryan is an engineer in the Sacramento Area with a focus in Python, Ruby, and Rust. Bash/Python Exercism mentor. Coding, physics, calculus, music, woodworking. Looking for work!
This is neat! I ended up using a HashMap of nodes and their children’s names, but that involves a lot of duplication. I was reading through the rust docs and saw that they recommended refcell> for stuff like this, but it was pretty intimidating.
Totally - I've gone the Rc<RefCell<T>> route for other projects, and it does get you there but it always feels hacky and brittle. In C++, you really just use the Rc-equivalent shared_ptr when you actually want multiple ownership over some data, not to skirt around language semantics when its convenient for you - this strategy is kinda antithetical to what draws me to Rust in the first place! There are definitely legitimate uses of runtime interior mutability but I don't feel this is one of them.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is neat! I ended up using a HashMap of nodes and their children’s names, but that involves a lot of duplication. I was reading through the rust docs and saw that they recommended refcell> for stuff like this, but it was pretty intimidating.
Totally - I've gone the
Rc<RefCell<T>>
route for other projects, and it does get you there but it always feels hacky and brittle. In C++, you really just use theRc
-equivalentshared_ptr
when you actually want multiple ownership over some data, not to skirt around language semantics when its convenient for you - this strategy is kinda antithetical to what draws me to Rust in the first place! There are definitely legitimate uses of runtime interior mutability but I don't feel this is one of them.