From d5d8897c847052680b25ea1511c4cac39a29a00d Mon Sep 17 00:00:00 2001 From: huntc Date: Thu, 6 Jan 2022 09:59:28 +1100 Subject: [PATCH] Remove unsafe from new on RND Unsafe is not required here given that all futures are required to live longer than their global peripheral instances. There are other occurrences of unsafe being used on new that should be removed. I started to do that but then went down a bit of a rabbit hole. --- embassy-nrf/src/rng.rs | 2 +- examples/nrf/src/bin/rng.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/embassy-nrf/src/rng.rs b/embassy-nrf/src/rng.rs index 645f9860..6b36cbb8 100644 --- a/embassy-nrf/src/rng.rs +++ b/embassy-nrf/src/rng.rs @@ -52,7 +52,7 @@ impl<'d> Rng<'d> { /// e.g. using `mem::forget`. /// /// The synchronous API is safe. - pub unsafe fn new( + pub fn new( _rng: impl Unborrow + 'd, irq: impl Unborrow + 'd, ) -> Self { diff --git a/examples/nrf/src/bin/rng.rs b/examples/nrf/src/bin/rng.rs index d12684e3..2f1a2699 100644 --- a/examples/nrf/src/bin/rng.rs +++ b/examples/nrf/src/bin/rng.rs @@ -15,7 +15,7 @@ use rand::Rng as _; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { - let mut rng = unsafe { Rng::new(p.RNG, interrupt::take!(RNG)) }; + let mut rng = Rng::new(p.RNG, interrupt::take!(RNG)); // Async API let mut bytes = [0; 4];