1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-01-24 14:26:20 +02:00

Update arc.md (#255)

Adding more information about `Arc`: what it stands for, costs and that reference cycles can occur.
This commit is contained in:
Igor Petruk 2023-01-23 10:57:10 +00:00 committed by GitHub
parent 8107a0ea2b
commit dc894b1e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,3 +23,12 @@ fn main() {
```
[1]: https://doc.rust-lang.org/std/sync/struct.Arc.html
<details>
* `Arc` stands for "Atomic Reference Counted", a thread safe version of `Rc` that uses atomic operations.
* `Arc::clone()` has the cost of atomic operations that get executed, but after that the use of the `T` is free.
* Beware of reference cycles, Rust does not have a garbage collector to detect those.
* `std::sync::Weak` can help.
</details>