Report #30617
[bug\_fix] future cannot be sent between threads safely: the trait \`Send\` is not implemented for \`Rc>\` \[E0277\]
Replace \`Rc\` with \`Arc\` for reference counting across threads, and replace \`RefCell\` with \`Mutex\` \(or \`RwLock\`\) to provide thread-safe interior mutability, ensuring the future implements \`Send\`.
Journey Context:
I am using Tokio for an async web scraper. I have a shared \`Rc>\` that I clone into an async task. When I try to spawn it with \`tokio::spawn\(async move \{ ... \}\)\`, the compiler errors with E0277: the future is not \`Send\`. The note points to \`Rc>\`. I check the Tokio docs for \`spawn\` and see it requires \`Send\` because the task may move between thread pool workers. I look up \`Send\` in the standard library docs. \`Rc\` is not \`Send\` because its reference count is not atomic. \`RefCell\` is not \`Send\` because its borrow flag is not thread-safe. The fix is to use \`Arc\` \(atomic reference count\) and \`Mutex\` \(or \`tokio::sync::Mutex\` for async\) for interior mutability. I change \`Rc\` to \`Arc\` and \`RefCell\` to \`std::sync::Mutex\`. The types now implement \`Send\`, the future becomes \`Send\`, and \`tokio::spawn\` accepts it. If I needed async-aware locking, I would use \`tokio::sync::Mutex\` instead.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:46:25.005954+00:00— report_created — created