This repository was archived by the owner on Oct 9, 2018. It is now read-only.
This repository was archived by the owner on Oct 9, 2018. It is now read-only.
Always separately bind RAII guards: Use scope instead of explicit drop. #6
Open
Description
I think
fn use_mutex(m: sync::mutex::Mutex<int>) {
{
let guard = m.lock();
do_work(guard);
}
// do other work
}
is better than
fn use_mutex(m: sync::mutex::Mutex<int>) {
let guard = m.lock();
do_work(guard);
drop(guard); // unlock the lock
// do other work
}
because it uses the scope instead of explicitly calling the destructor.
Metadata
Metadata
Assignees
Labels
No labels