From bb34087a1a766290da1ac7d5a94c32578bc2d28d Mon Sep 17 00:00:00 2001 From: Ethan Brierley Date: Wed, 1 Nov 2023 19:43:06 +0000 Subject: [PATCH] feat: make associated functions on `Secret` `#[must_use]` --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index bb41e4d..a61add9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,19 +23,23 @@ pub struct Secret(T); impl Secret { /// See [module level documentation][crate] #[inline] + #[must_use = "the secret will be dropped if not used"] pub const fn new(secret: T) -> Self { Self(secret) } #[inline] + #[must_use] pub fn from(secret: impl Into) -> Self { Self(secret.into()) } #[inline] + #[must_use] pub fn try_from>(secret: U) -> Result> { secret.try_into().map(Self).map_err(Secret) } /// See [module level documentation][crate] #[inline] + #[must_use = "expose_secret does nothing unless used"] pub const fn expose_secret(&self) -> &T { &self.0 }