Skip to content

Commit c64a34e

Browse files
Doc the benefits of Send for RcBox
1 parent 0fe399f commit c64a34e

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

crates/rc-box/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ With the standard library types, you would use `get_mut` and have to handle the
77
case where the value was shared. With the known unique versions, you have `DerefMut`,
88
so it's as simple as mutating behind a `Box`.
99

10+
Also note that `RcBox`, unlike `Rc`, implements `Send` and `Sync`. An `RcBox` can be sent to
11+
another thread or stored in a shared collection, and then converted to an `Rc` for optimal
12+
single-threaded use. This works for `Rc<RefCell<T>` as well, since `RefCell` is `Send`.
13+
1014
## Related Crates
1115

1216
- [`erasable`](https://lib.rs/crates/erasable): Erase pointers of their concrete type.

crates/rc-box/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
//! With the standard library types, you would use `get_mut` and have to handle the impossible
99
//! case where the value was shared. With the known unique versions, you have [`DerefMut`],
1010
//! so it's as simple as mutating behind a [`Box`].
11+
//!
12+
//! Also note that `RcBox`, unlike `Rc`, implements `Send` and `Sync`. An `RcBox` can be sent to
13+
//! another thread or stored in a shared collection, and then converted to an `Rc` for optimal
14+
//! single-threaded use. This works for `Rc<RefCell<T>` as well, since `RefCell` is `Send`.
1115
1216
#![warn(missing_docs, missing_debug_implementations)]
1317
#![no_std]

0 commit comments

Comments
 (0)