File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 36
36
37
37
extern crate alloc;
38
38
39
- use alloc:: { boxed:: Box , string:: String } ;
39
+ use alloc:: { boxed:: Box , string:: String , vec :: Vec } ;
40
40
use core:: {
41
41
any,
42
42
fmt:: { self , Debug } ,
@@ -167,6 +167,23 @@ impl<S: Zeroize + ?Sized> ExposeSecretMut<S> for SecretBox<S> {
167
167
}
168
168
}
169
169
170
+ /// Secret slice type.
171
+ ///
172
+ /// This is a type alias for [`SecretBox<[S]>`] which supports some helpful trait impls.
173
+ ///
174
+ /// Notably it has a [`From<Vec<S>>`] impl which is the preferred method for construction.
175
+ pub type SecretSlice < S > = SecretBox < [ S ] > ;
176
+
177
+ impl < S > From < Vec < S > > for SecretSlice < S >
178
+ where
179
+ S : Zeroize ,
180
+ [ S ] : Zeroize ,
181
+ {
182
+ fn from ( vec : Vec < S > ) -> Self {
183
+ Self :: from ( vec. into_boxed_slice ( ) )
184
+ }
185
+ }
186
+
170
187
/// Secret string type.
171
188
///
172
189
/// This is a type alias for [`SecretBox<str>`] which supports some helpful trait impls.
You can’t perform that action at this time.
0 commit comments