File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,20 @@ pub trait RngCore {
208
208
/// [`BlockRngCore`]: block::BlockRngCore
209
209
pub trait CryptoRng { }
210
210
211
+ /// An extension trait to support trait objects that implement [`RngCore`] and
212
+ /// [`CryptoRng`]. Upcasting to [`RngCore`] is supported via the
213
+ /// [`CryptoRngCore::upcast`] method.
214
+ pub trait CryptoRngCore : RngCore {
215
+ /// Upcast to an [`RngCore`] trait object.
216
+ fn upcast ( & mut self ) -> & mut dyn RngCore ;
217
+ }
218
+
219
+ impl < T : CryptoRng + RngCore > CryptoRngCore for T {
220
+ fn upcast ( & mut self ) -> & mut dyn RngCore {
221
+ self
222
+ }
223
+ }
224
+
211
225
/// A random number generator that can be explicitly seeded.
212
226
///
213
227
/// This trait encapsulates the low-level functionality common to all
You can’t perform that action at this time.
0 commit comments