Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Designs and reviews Rust ownership, borrowing, lifetimes, and interior mutability so data flow matches the domain model.
91% 95%+5 ptsof test cases passed
Passed 21 of 22 test cases with the skill, and 20 of 22 without it.
I am getting compiler error E0502 in my Rust project because I'm trying to modify elements inside a collection while simultaneously holding an active read reference to it. Here is the offending function snippet. Please refactor the code to resolve the borrow checker conflict, and provide a clear explanation of how ownership and reference lifetimes were adjusted.
The response refactors the code using standard slice or collection API methods rather than raw index lookup loops.
3 of 3 safety checks passed
Use this skill to make ownership shape match the program's data flow. Treat borrow-checker errors as design feedback: decide who owns each value, how long access must last, and whether mutation needs exclusivity or a different data shape.
Rc<RefCell<_>>.Rc for single-threaded shared ownership and Arc for cross-thread
shared ownership. Add Cell, RefCell, Mutex, or RwLock only when the
mutation model is explicit.T when the function consumes or stores the value.&T when the function only reads during the call.&mut T when the function must mutate and no other access should occur.&Vec<T>, &String, or &PathBuf when &[T], &str, or
&Path expresses the needed capability.Read references/borrow-patterns.md when resolving non-trivial compiler
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.