2 ms·
Instead of using unsafe code, I would use RefCell first: «a mutable memory location with dynamically checked borrow rules» https://doc.rust-lang.org/std/cell/s
by _nalply 10y ago
Instead of using unsafe code, I would use RefCell first: «a mutable memory location with dynamically checked borrow rules»
https://doc.rust-lang.org/std/cell/struct.RefCell.html https://doc.rust-lang.org/std/cell/struct.RefCell.html
Using clone() also often helps. clone() has an overhead since you copy bytes, but sometimes you need to get something working right first, then optimise.
There are other tricks if the borrow checker interferes.