@@ -21,6 +21,7 @@ question: |-
2121 requires_send(arc_data);
2222 requires_send(mutex_data);
2323 requires_sync(refcell_data);
24+ requires_send(rc_data);
2425 }
2526 ```
2627
@@ -30,7 +31,7 @@ answers:
3031- Only the `requires_send(rc_data)` line
3132- Both `requires_send(rc_data)` and `requires_sync(refcell_data)` lines
3233- All function calls work without errors
33- correct_answer : 0
34+ correct_answer : 2
3435expected_output :
3536- error[E0277]
3637- cannot be shared between threads safely
@@ -59,11 +60,10 @@ explanation: |-
5960 - `Mutex<T>` is both `Send` and `Sync` (when `T: Send`) because it provides
6061 thread-safe interior mutability through locking.
6162
62- In the code, `rc_data` is created but never used in a function call, so it
63- doesn't cause an error. The calls `requires_send(arc_data)` and
64- `requires_send(mutex_data)` both succeed because `Arc` and `Mutex` implement
65- `Send`. However, `requires_sync(refcell_data)` fails to compile because
66- `RefCell` does not implement `Sync`.
63+ The calls `requires_send(arc_data)` and `requires_send(mutex_data)` both succeed
64+ because `Arc` and `Mutex` implement `Send`. However, `requires_sync(refcell_data)`
65+ and `requires_send(rc_data)` both fail to compile. The former fails because `RefCell`
66+ does not implement `Sync`, and the latter because `Rc` does not implement `Send`.
6767
6868 The key takeaway is that `RefCell` provides interior mutability for
6969 single-threaded scenarios, while `Mutex` provides thread-safe interior
0 commit comments