diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ccae00f..ac756b5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,6 +19,10 @@ jobs: include: - version: stable features: --features mint + - version: stable + features: --features bytemuck + - version: stable + features: --features arbitrary - version: nightly features: --features unstable - version: nightly @@ -40,9 +44,6 @@ jobs: env: RUST_BACKTRACE: 1 - - name: bytemuck - run: cargo check --features bytemuck - build_result: name: Result runs-on: ubuntu-latest diff --git a/src/angle.rs b/src/angle.rs index a503df6..51888ae 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -23,7 +23,6 @@ use bytemuck::{Zeroable, Pod}; /// An angle in radians #[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct Angle { pub radians: T, } @@ -34,6 +33,23 @@ unsafe impl Zeroable for Angle {} #[cfg(feature = "bytemuck")] unsafe impl Pod for Angle {} +#[cfg(feature = "arbitrary")] +impl<'a, T> arbitrary::Arbitrary<'a> for Angle +where + T: arbitrary::Arbitrary<'a>, +{ + // This implementation could be derived, but the derive would require an `extern crate std`. + fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { + Ok(Angle { + radians: arbitrary::Arbitrary::arbitrary(u)?, + }) + } + + fn size_hint(depth: usize) -> (usize, Option) { + ::size_hint(depth) + } +} + impl Angle { #[inline] pub fn radians(radians: T) -> Self {