File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -476,6 +476,14 @@ where
476
476
}
477
477
}
478
478
479
+ impl Zeroize for str {
480
+ fn zeroize ( & mut self ) {
481
+ // Safety:
482
+ // A zeroized byte slice is a valid UTF-8 string.
483
+ unsafe { self . as_bytes_mut ( ) . zeroize ( ) }
484
+ }
485
+ }
486
+
479
487
/// [`PhantomData`] is always zero sized so provide a [`Zeroize`] implementation.
480
488
impl < Z > Zeroize for PhantomData < Z > {
481
489
fn zeroize ( & mut self ) { }
@@ -588,6 +596,14 @@ where
588
596
#[ cfg_attr( docsrs, doc( cfg( feature = "alloc" ) ) ) ]
589
597
impl < Z > ZeroizeOnDrop for Box < [ Z ] > where Z : ZeroizeOnDrop { }
590
598
599
+ #[ cfg( feature = "alloc" ) ]
600
+ #[ cfg_attr( docsrs, doc( cfg( feature = "alloc" ) ) ) ]
601
+ impl Zeroize for Box < str > {
602
+ fn zeroize ( & mut self ) {
603
+ self . as_mut ( ) . zeroize ( ) ;
604
+ }
605
+ }
606
+
591
607
#[ cfg( feature = "alloc" ) ]
592
608
#[ cfg_attr( docsrs, doc( cfg( feature = "alloc" ) ) ) ]
593
609
impl Zeroize for String {
You can’t perform that action at this time.
0 commit comments