1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-15 06:20:32 +02:00

Use Arc::clone instead of .clone() (#1023)

The fully qualified syntax is recommended for `Arc` which implements all methods as associated methods.
This commit is contained in:
Martin Geisler 2023-07-24 20:19:06 +02:00 committed by GitHub
parent a2367b4d93
commit e8ea741cea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,8 +62,8 @@ fn main() {
for i in 0..forks.len() {
let tx = tx.clone();
let mut left_fork = forks[i].clone();
let mut right_fork = forks[(i + 1) % forks.len()].clone();
let mut left_fork = Arc::clone(&forks[i]);
let mut right_fork = Arc::clone(&forks[(i + 1) % forks.len()]);
// To avoid a deadlock, we have to break the symmetry
// somewhere. This will swap the forks without deinitializing