diff options
Diffstat (limited to 'src/docs/let_underscore_lock.txt')
| -rw-r--r-- | src/docs/let_underscore_lock.txt | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/src/docs/let_underscore_lock.txt b/src/docs/let_underscore_lock.txt deleted file mode 100644 index bd8217fb58b..00000000000 --- a/src/docs/let_underscore_lock.txt +++ /dev/null @@ -1,20 +0,0 @@ -### What it does -Checks for `let _ = sync_lock`. -This supports `mutex` and `rwlock` in `std::sync` and `parking_lot`. - -### Why is this bad? -This statement immediately drops the lock instead of -extending its lifetime to the end of the scope, which is often not intended. -To extend lock lifetime to the end of the scope, use an underscore-prefixed -name instead (i.e. _lock). If you want to explicitly drop the lock, -`std::mem::drop` conveys your intention better and is less error-prone. - -### Example -``` -let _ = mutex.lock(); -``` - -Use instead: -``` -let _lock = mutex.lock(); -``` \ No newline at end of file |
