Skip to content

Doc the benefits of Send for RcBox #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/rc-box/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ With the standard library types, you would use `get_mut` and have to handle the
case where the value was shared. With the known unique versions, you have `DerefMut`,
so it's as simple as mutating behind a `Box`.

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

## Related Crates

- [`erasable`](https://lib.rs/crates/erasable): Erase pointers of their concrete type.
Expand Down
4 changes: 4 additions & 0 deletions crates/rc-box/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
//! With the standard library types, you would use `get_mut` and have to handle the impossible
//! case where the value was shared. With the known unique versions, you have [`DerefMut`],
//! so it's as simple as mutating behind a [`Box`].
//!
//! Also note that `RcBox`, unlike `Rc`, implements `Send` and `Sync`. An `RcBox` can be sent to
//! another thread or stored in a shared collection, and then converted to an `Rc` for optimal
//! single-threaded use. This works for `Rc<RefCell<T>` as well, since `RefCell` is `Send`.

#![warn(missing_docs, missing_debug_implementations)]
#![no_std]
Expand Down
Loading