Codex Rust Resource Ownership with Rc, Arc, and Weak
Choose borrowing or reference counting according to ownership and thread boundaries. Review how weak links affect resource lifetime.
中文Install in Codex
Codex, a Rust checkout and Cargo. The example uses local practice data.
- Copy the pinned `skills/rust-resource/` directory into `.agents/skills/rust-resource/` in the project.
- Select `$rust-resource` and describe owners, thread boundaries, and mutation needs.
Example task
In a practice tree, a parent owns child nodes. Ask how a child can refer back to the parent without extending its lifetime.What to check
The explanation shows how to upgrade the weak parent reference and how to handle a parent that is already gone.
Original SKILL.md on GitHub · Updated
Frequently asked question
Does read-only single-thread sharing require Arc?
Prefer a borrow where possible. Rc is available when single-thread reference counting is needed.