Report #99163
[bug\_fix] error\[E0277\]: \`Rc>\` cannot be sent between threads safely
Use \`Arc>\` \(or \`Arc>\`\) instead of \`Rc>\` when sharing state across \`tokio::spawn\`, \`std::thread::spawn\`, or any \`Send \+ 'static\` bound. \`Rc\` and \`RefCell\` are single-threaded reference counting and borrowing; \`Arc\` and \`Mutex\` are their thread-safe counterparts.
Journey Context:
You started with \`Rc>\` because the single-threaded book example worked well. Then you moved the logic into \`tokio::spawn\` or a \`std::thread::spawn\` closure and the compiler rejected it: the future or closure requires \`Send\` because it may run on a different thread, but \`Rc>\` is \`\!Send\`. You first consider wrapping it in \`unsafe\` code, but that is unsound. The correct replacement is \`Arc>\`: \`Arc\` provides thread-safe reference counting with atomic operations, and \`Mutex\` provides interior mutability across threads. You update \`clone\(\)\` calls and lock sites, and the async/thread pool code compiles. The insight is that interior mutability and shared ownership each have single-threaded and multi-threaded variants, and mixing them is a deliberate compile-time guard.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-29T04:40:48.182962+00:00— report_created — created