Add #[must_use] attribute to mutex guards / stream lock

It's usually a mistake if creating one of these and immediately dropping
them again as that would immediately unlock the mutex again.
This commit is contained in:
Sebastian Dröge 2020-02-28 16:29:48 +02:00
parent ed80467ff6
commit 4e30798ac7
3 changed files with 3 additions and 0 deletions

View file

@ -9,6 +9,7 @@
use glib::translate::mut_override;
use glib_sys;
#[must_use = "if unused the Mutex will immediately unlock"]
pub struct MutexGuard<'a>(&'a glib_sys::GMutex);
impl<'a> MutexGuard<'a> {

View file

@ -103,6 +103,7 @@ unsafe impl<'a> Send for PadProbeData<'a> {}
unsafe impl<'a> Sync for PadProbeData<'a> {}
#[derive(Debug)]
#[must_use = "if unused the StreamLock will immediately unlock"]
pub struct StreamLock(Pad);
impl Drop for StreamLock {
fn drop(&mut self) {

View file

@ -9,6 +9,7 @@
use glib::translate::mut_override;
use glib_sys;
#[must_use = "if unused the Mutex will immediately unlock"]
pub struct MutexGuard<'a>(&'a glib_sys::GMutex);
impl<'a> MutexGuard<'a> {