Skip to content

Commit 9c431f9

Browse files
committed
add rkyv support
1 parent 0c5e422 commit 9c431f9

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
rust: [
1616
1.31.0, # 2018!
1717
1.36.0, # rand
18+
1.54.0, # rkyv
1819
stable,
1920
beta,
2021
nightly

Cargo.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ exclude = ["/bors.toml", "/ci/*", "/.github/*"]
1414
edition = "2018"
1515

1616
[package.metadata.docs.rs]
17-
features = ["bytemuck", "std", "serde", "rand"]
17+
features = ["bytemuck", "std", "serde", "rkyv", "bytecheck", "rand"]
1818

1919
[dependencies]
2020

@@ -32,6 +32,15 @@ optional = true
3232
version = "1.0"
3333
default-features = false
3434

35+
[dependencies.rkyv]
36+
optional = true
37+
version = "0.7"
38+
default-features = false
39+
40+
[dependencies.bytecheck]
41+
optional = true
42+
version = "0.6"
43+
3544
[dependencies.rand]
3645
optional = true
3746
version = "0.8"
@@ -41,3 +50,6 @@ default-features = false
4150
default = ["std"]
4251
std = ["num-traits/std"]
4352
libm = ["num-traits/libm"]
53+
54+
[dev-dependencies]
55+
rkyv = { version = "0.7", default-features = false, features = ["size_64"] }

ci/rustup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
set -ex
66

77
ci=$(dirname $0)
8-
for version in 1.31.0 1.36.0 stable beta nightly; do
8+
for version in 1.31.0 1.36.0 1.54.0 stable beta nightly; do
99
rustup run "$version" "$ci/test_full.sh"
1010
done

ci/test_full.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ fi
3030
FEATURES=(libm serde)
3131
check_version 1.34 && FEATURES+=(bytemuck)
3232
check_version 1.36 && FEATURES+=(rand)
33+
check_version 1.54 && FEATURES+=(rkyv)
3334
echo "Testing supported features: ${FEATURES[*]}"
3435

3536
set -x

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ pub use crate::crand::ComplexDistribution;
7979
/// ```
8080
#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug, Default)]
8181
#[repr(C)]
82+
#[cfg_attr(
83+
feature = "rkyv",
84+
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize,),
85+
archive(as = "Complex<T::Archived>", bound(archive = "T: rkyv::Archive"))
86+
)]
87+
#[cfg_attr(feature = "bytecheck", derive(bytecheck::CheckBytes))]
8288
pub struct Complex<T> {
8389
/// Real portion of the complex number
8490
pub re: T,

0 commit comments

Comments
 (0)