From 0cd57725f9d624aed3cdaa3852a1f80f550ae275 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 26 Mar 2024 21:38:28 -0400 Subject: [PATCH] Update `RwLock` deadlock example to not use shadowing Tweak variable names in the deadlock example to remove any potential confusion that the behavior is somehow shadowing-related. --- library/std/src/sync/rwlock.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index d648cd089943f..e0a8a7603d71a 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -31,13 +31,14 @@ use crate::sys::sync as sys; ///
Potential deadlock example /// /// ```text -/// // Thread 1 | // Thread 2 -/// let _rg = lock.read(); | -/// | // will block -/// | let _wg = lock.write(); -/// // may deadlock | -/// let _rg = lock.read(); | +/// // Thread 1 | // Thread 2 +/// let _rg1 = lock.read(); | +/// | // will block +/// | let _wg = lock.write(); +/// // may deadlock | +/// let _rg2 = lock.read(); | /// ``` +/// ///
/// /// The type parameter `T` represents the data that this lock protects. It is