this post was submitted on 18 Jun 2023
14 points (93.8% liked)
Rust
6029 readers
1 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I believe the video is somewhat incorrect: Arc (and Rc) need a reference count, which you missed in your description of the overhead. (EDIT: You mentioned this later in the video. )
The downside of all of Arc or Rc is of course (as you pointed out towards the end of the video) that you need to do all that reference counting and store the reference count (as I mentioned above). A box of a slice would indeed be cheaper. But if the data is static (or will at least live for the rest of the program), you might consider just leaking it (Box::leak) to get a static lifetime reference. That can then be cheaply shared.
I want to be clear that I didn't make this video. I just thought it was worthy of sharing as someone who doesn't have a good handle on Rust or best practices in using Rust.