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.
This commit is contained in:
parent
da0c25227f
commit
d5d8897c84
@ -52,7 +52,7 @@ impl<'d> Rng<'d> {
|
|||||||
/// e.g. using `mem::forget`.
|
/// e.g. using `mem::forget`.
|
||||||
///
|
///
|
||||||
/// The synchronous API is safe.
|
/// The synchronous API is safe.
|
||||||
pub unsafe fn new(
|
pub fn new(
|
||||||
_rng: impl Unborrow<Target = RNG> + 'd,
|
_rng: impl Unborrow<Target = RNG> + 'd,
|
||||||
irq: impl Unborrow<Target = interrupt::RNG> + 'd,
|
irq: impl Unborrow<Target = interrupt::RNG> + 'd,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -15,7 +15,7 @@ use rand::Rng as _;
|
|||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
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
|
// Async API
|
||||||
let mut bytes = [0; 4];
|
let mut bytes = [0; 4];
|
||||||
|
Loading…
Reference in New Issue
Block a user