We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Secret
#[must_use]
1 parent 3170192 commit f0c2496Copy full SHA for f0c2496
src/lib.rs
@@ -23,19 +23,23 @@ pub struct Secret<T>(T);
23
impl<T> Secret<T> {
24
/// See [module level documentation][crate]
25
#[inline]
26
+ #[must_use = "the secret will be dropped if not used"]
27
pub const fn new(secret: T) -> Self {
28
Self(secret)
29
}
30
31
+ #[must_use]
32
pub fn from(secret: impl Into<T>) -> Self {
33
Self(secret.into())
34
35
36
37
pub fn try_from<U: TryInto<T>>(secret: U) -> Result<Self, Secret<U::Error>> {
38
secret.try_into().map(Self).map_err(Secret)
39
40
41
42
+ #[must_use = "expose_secret does nothing unless used"]
43
pub const fn expose_secret(&self) -> &T {
44
&self.0
45
0 commit comments