Skip to content

Commit 9dc2559

Browse files
committed
derive Immutable and KnownLayout for f16 and bf16
1 parent 989d270 commit 9dc2559

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/bfloat.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use core::{
2020
#[cfg(feature = "serde")]
2121
use serde::{Deserialize, Serialize};
2222
#[cfg(feature = "zerocopy")]
23-
use zerocopy::{FromBytes, IntoBytes};
23+
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
2424

2525
pub(crate) mod convert;
2626

@@ -42,7 +42,10 @@ pub(crate) mod convert;
4242
)]
4343
#[cfg_attr(feature = "rkyv", rkyv(resolver = Bf16Resolver))]
4444
#[cfg_attr(feature = "bytemuck", derive(Zeroable, Pod))]
45-
#[cfg_attr(feature = "zerocopy", derive(IntoBytes, FromBytes))]
45+
#[cfg_attr(
46+
feature = "zerocopy",
47+
derive(FromBytes, Immutable, IntoBytes, KnownLayout)
48+
)]
4649
#[cfg_attr(kani, derive(kani::Arbitrary))]
4750
pub struct bf16(u16);
4851

src/binary16.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use core::{
2020
#[cfg(feature = "serde")]
2121
use serde::{Deserialize, Serialize};
2222
#[cfg(feature = "zerocopy")]
23-
use zerocopy::{FromBytes, IntoBytes};
23+
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
2424

2525
pub(crate) mod arch;
2626

@@ -41,7 +41,10 @@ pub(crate) mod arch;
4141
)]
4242
#[cfg_attr(feature = "rkyv", rkyv(resolver = F16Resolver))]
4343
#[cfg_attr(feature = "bytemuck", derive(Zeroable, Pod))]
44-
#[cfg_attr(feature = "zerocopy", derive(IntoBytes, FromBytes))]
44+
#[cfg_attr(
45+
feature = "zerocopy",
46+
derive(FromBytes, Immutable, IntoBytes, KnownLayout)
47+
)]
4548
#[cfg_attr(kani, derive(kani::Arbitrary))]
4649
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
4750
pub struct f16(u16);

0 commit comments

Comments
 (0)