From c55152017ea3365172b82738291a5e02df0f13ef Mon Sep 17 00:00:00 2001 From: Botahamec Date: Thu, 27 Oct 2022 18:41:23 -0400 Subject: Added cargo warnings --- src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 0c873be..0a0fc09 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,6 @@ +#![warn(clippy::pedantic)] +#![warn(clippy::nursery)] + use std::any::type_name; use std::fmt::{self, Debug}; use std::marker::PhantomData; @@ -26,11 +29,12 @@ impl Debug for ThreadKey { } impl ThreadKey { - /// Get the current thread's `ThreadKey, if it's not already taken. + /// Get the current thread's `ThreadKey`, if it's not already taken. /// /// The first time this is called, it will successfully return a /// `ThreadKey`. However, future calls to this function will return /// [`None`], unless the key is dropped or unlocked first. + #[must_use] pub fn lock() -> Option { KEY.get_or_default().try_lock().map(|key| Self { phantom: PhantomData, @@ -42,7 +46,7 @@ impl ThreadKey { /// /// After this method is called, a call to [`ThreadKey::lock`] will return /// this `ThreadKey`. - pub fn unlock(key: ThreadKey) { - drop(key) + pub fn unlock(key: Self) { + drop(key); } } -- cgit v1.2.3