diff options
| author | Botahamec <botahamec@outlook.com> | 2022-10-27 18:41:23 -0400 |
|---|---|---|
| committer | Botahamec <botahamec@outlook.com> | 2022-10-27 18:41:23 -0400 |
| commit | c55152017ea3365172b82738291a5e02df0f13ef (patch) | |
| tree | bd7ed45dff8ce577de1fcfb74e7f9c9520ddb30c /src/lib.rs | |
| parent | 7b0675a1e42341030bbb9ad98d41a321296e1ecc (diff) | |
Added cargo warnings
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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<Self> { 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); } } |
