Skip to content

Commit

Permalink
Merge #110
Browse files Browse the repository at this point in the history
110: add rkyv support r=cuviper a=zyansheep

For some reason github closed the old PR while I was trying to merge master into the old pr.
Should've used rebase!

Co-authored-by: zyansheep <zyansheep@protonmail.com>
Co-authored-by: Josh Stone <cuviper@gmail.com>
  • Loading branch information
3 people authored Jan 19, 2023
2 parents 0c5e422 + dd3a23f commit d33abcb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
rust: [
1.31.0, # 2018!
1.36.0, # rand
1.54.0, # rkyv
stable,
beta,
nightly
Expand Down
12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exclude = ["/bors.toml", "/ci/*", "/.github/*"]
edition = "2018"

[package.metadata.docs.rs]
features = ["bytemuck", "std", "serde", "rand"]
features = ["bytemuck", "std", "serde", "rkyv/size_64", "bytecheck", "rand"]

[dependencies]

Expand All @@ -32,6 +32,16 @@ optional = true
version = "1.0"
default-features = false

[dependencies.rkyv]
optional = true
version = "0.7"
default-features = false

[dependencies.bytecheck]
optional = true
version = "0.6"
default-features = false

[dependencies.rand]
optional = true
version = "0.8"
Expand Down
1 change: 1 addition & 0 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
status = [
"Test (1.31.0)",
"Test (1.36.0)",
"Test (1.54.0)",
"Test (stable)",
"Test (beta)",
"Test (nightly)",
Expand Down
2 changes: 1 addition & 1 deletion ci/rustup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
set -ex

ci=$(dirname $0)
for version in 1.31.0 1.36.0 stable beta nightly; do
for version in 1.31.0 1.36.0 1.54.0 stable beta nightly; do
rustup run "$version" "$ci/test_full.sh"
done
8 changes: 7 additions & 1 deletion ci/test_full.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down Expand Up @@ -30,8 +30,14 @@ fi
FEATURES=(libm serde)
check_version 1.34 && FEATURES+=(bytemuck)
check_version 1.36 && FEATURES+=(rand)
check_version 1.54 && FEATURES+=(rkyv/size_64 bytecheck)
echo "Testing supported features: ${FEATURES[*]}"

cargo generate-lockfile

# libm 0.2.6 started using {float}::EPSILON
check_version 1.43 || cargo update -p libm --precise 0.2.5

set -x

# test the default
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ pub use crate::crand::ComplexDistribution;
/// ```
#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug, Default)]
#[repr(C)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
)]
#[cfg_attr(feature = "rkyv", archive(as = "Complex<T::Archived>"))]
#[cfg_attr(feature = "bytecheck", derive(bytecheck::CheckBytes))]
pub struct Complex<T> {
/// Real portion of the complex number
pub re: T,
Expand Down

0 comments on commit d33abcb

Please sign in to comment.