From e343fd30078ab71865fe1509f81d7c396a851c00 Mon Sep 17 00:00:00 2001 From: ROMemories Date: Mon, 15 Apr 2024 15:34:20 +0200 Subject: [PATCH] refactor(random): rewrite a static assert checking for an impl This verifies that `SelectedRng` is indeed a CSRNG using a shorter, arguably easier to read construct. It is also easier to make clippy happy about it. --- src/riot-rs-random/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/riot-rs-random/src/lib.rs b/src/riot-rs-random/src/lib.rs index 1b4d85486..5f8e56a43 100644 --- a/src/riot-rs-random/src/lib.rs +++ b/src/riot-rs-random/src/lib.rs @@ -125,10 +125,8 @@ mod csprng { impl rand_core::CryptoRng for super::CryptoRng {} /// Asserts that SelectedRng is CryptoRng, justifying the implementation above. - fn static_assert_is_cryptorng() -> impl rand_core::CryptoRng { - let result: super::SelectedRng = unreachable!("This function is for type checking only"); - result - } + trait _AssertCryptoRng: rand_core::CryptoRng {} + impl _AssertCryptoRng for SelectedRng {} } /// Populates the global RNG from a seed value.