Skip to content

Commit

Permalink
Remove unsafe keyword for Platform trait
Browse files Browse the repository at this point in the history
My guess is that it was unsafe to encourage people to use the platform!
macro, but there is no downside to implementing the trait manually and
often the macro is not flexible enough.  So this patch removes the
unsafe keyword for the Platform trait.
  • Loading branch information
robin-nitrokey committed Mar 7, 2025
1 parent ec9bee8 commit 8d0b1b9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed the storage types to return `&dyn DynFilesystem` instead.
- Removed the `Copy` requirement.
- Removed the `unsafe` keyword for the `Store` trait.
- Removed the `unsafe` keyword for the `Platform` trait.

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub trait UserInterface {
// This is the same trick as in "store.rs",
// replacing generic parameters with associated types
// and a macro.
pub unsafe trait Platform {
pub trait Platform {
// temporarily remove CryptoRng bound until HALs come along
type R: CryptoRng + RngCore;
type S: Store;
Expand Down Expand Up @@ -92,7 +92,7 @@ macro_rules! platform {
}
}

unsafe impl $crate::platform::Platform for $PlatformName {
impl $crate::platform::Platform for $PlatformName {
type R = $Rng;
type S = $Store;
type UI = $UserInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/virt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl Platform<'_> {
}
}

unsafe impl<'a> platform::Platform for Platform<'a> {
impl<'a> platform::Platform for Platform<'a> {
type R = ChaCha8Rng;
type S = store::Store<'a>;
type UI = UserInterface;
Expand Down

0 comments on commit 8d0b1b9

Please sign in to comment.