File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -476,6 +476,14 @@ where
476476 }
477477}
478478
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+
479487/// [`PhantomData`] is always zero sized so provide a [`Zeroize`] implementation.
480488impl < Z > Zeroize for PhantomData < Z > {
481489 fn zeroize ( & mut self ) { }
@@ -588,6 +596,14 @@ where
588596#[ cfg_attr( docsrs, doc( cfg( feature = "alloc" ) ) ) ]
589597impl < Z > ZeroizeOnDrop for Box < [ Z ] > where Z : ZeroizeOnDrop { }
590598
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+
591607#[ cfg( feature = "alloc" ) ]
592608#[ cfg_attr( docsrs, doc( cfg( feature = "alloc" ) ) ) ]
593609impl Zeroize for String {
You can’t perform that action at this time.
0 commit comments