File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,15 @@ pub trait Generator {
5959 ///
6060 /// This must fill `output` with random data.
6161 fn generate ( & mut self , output : & mut Self :: Output ) ;
62+
63+ /// Destruct the output buffer
64+ ///
65+ /// This method is called on [`Drop`] of the [`Self::Output`] buffer.
66+ /// The default implementation does nothing.
67+ #[ inline]
68+ fn drop ( & mut self , output : & mut Self :: Output ) {
69+ let _ = output;
70+ }
6271}
6372
6473/// A cryptographically secure generator
@@ -124,6 +133,12 @@ impl<G: Generator + fmt::Debug> fmt::Debug for BlockRng<G> {
124133 }
125134}
126135
136+ impl < G : Generator > Drop for BlockRng < G > {
137+ fn drop ( & mut self ) {
138+ self . core . drop ( & mut self . results ) ;
139+ }
140+ }
141+
127142impl < const N : usize , G : Generator < Output = [ u32 ; N ] > > BlockRng < G > {
128143 /// Create a new `BlockRng` from an existing RNG implementing
129144 /// `Generator`. Results will be generated on first use.
You can’t perform that action at this time.
0 commit comments