567: Remove unsafe from new on RND r=Dirbaio a=huntc

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. Therefore, just confining this PR to what I'm currently exposed to.

Co-authored-by: huntc <huntchr@gmail.com>
This commit is contained in:
bors[bot] 2022-01-06 10:15:46 +00:00 committed by GitHub
commit 82e5edb940
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -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 {

View file

@ -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];