Skip to content

Commit 1624bed

Browse files
committed
Derive zerocopy traits on Archivedf16 and Archivedbf16 via rkyv passthrough
Requires rkyv 0.8.X (the version that ships rkyv/rkyv#677, the `rkyv/zerocopy` feature passthrough to `rend/zerocopy-0_8`).
1 parent 688f1e2 commit 1624bed

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ alloc = []
2121
rand_distr = ["dep:rand", "dep:rand_distr"]
2222
zerocopy = [] # Deprecated
2323
nightly = []
24+
rkyv = ["dep:rkyv", "rkyv/zerocopy"]
2425

2526
[dependencies]
2627
cfg-if = "1.0.0"
@@ -61,3 +62,4 @@ harness = false
6162
[package.metadata.docs.rs]
6263
rustdoc-args = ["--cfg", "docsrs"]
6364
all-features = true
65+

src/bfloat.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ pub(crate) mod convert;
3939
feature = "rkyv",
4040
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
4141
)]
42-
#[cfg_attr(feature = "rkyv", rkyv(resolver = Bf16Resolver))]
42+
#[cfg_attr(
43+
feature = "rkyv",
44+
rkyv(
45+
resolver = Bf16Resolver,
46+
derive(zerocopy::FromBytes, zerocopy::IntoBytes,
47+
zerocopy::Immutable, zerocopy::KnownLayout),
48+
)
49+
)]
4350
#[cfg_attr(feature = "bytemuck", derive(Zeroable, Pod))]
4451
#[cfg_attr(kani, derive(kani::Arbitrary))]
4552
#[derive(FromBytes, Immutable, IntoBytes, KnownLayout)]

src/binary16.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ pub(crate) mod arch;
3838
feature = "rkyv",
3939
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
4040
)]
41-
#[cfg_attr(feature = "rkyv", rkyv(resolver = F16Resolver))]
41+
#[cfg_attr(
42+
feature = "rkyv",
43+
rkyv(
44+
resolver = F16Resolver,
45+
derive(zerocopy::FromBytes, zerocopy::IntoBytes,
46+
zerocopy::Immutable, zerocopy::KnownLayout),
47+
)
48+
)]
4249
#[cfg_attr(feature = "bytemuck", derive(Zeroable, Pod))]
4350
#[cfg_attr(kani, derive(kani::Arbitrary))]
4451
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]

0 commit comments

Comments
 (0)