Skip to content

Commit

Permalink
Add static checks for Clone, Copy, Send, Sync, and Hash.
Browse files Browse the repository at this point in the history
Part of #29.
  • Loading branch information
iliekturtles committed Dec 13, 2017
1 parent f11af4f commit 9534c02
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,3 +889,47 @@ mod quantities_macro {
}
}
}

mod static_checks {
storage_types! {
types: Float;

use tests::*;

fn _assert_static() {
assert::<Quantity<Q<::typenum::Z0, ::typenum::Z0>, U<V>, V>>();

fn assert<T: Clone + Copy + Send + Sync>() {}
}
}

storage_types! {
types: PrimInt, Rational, Rational32, Rational64;

use tests::*;

fn _assert_static() {
assert::<Quantity<Q<::typenum::Z0, ::typenum::Z0>, U<V>, V>>();

#[cfg(feature = "std")]
fn assert<T: Clone + Copy + Send + Sync + ::stdlib::hash::Hash>() {}
#[cfg(not(feature = "std"))]
fn assert<T: Clone + Copy + Send + Sync>() {}
}
}

storage_types! {
types: BigInt, BigUint, BigRational;

use tests::*;

fn _assert_static() {
assert::<Quantity<Q<::typenum::Z0, ::typenum::Z0>, U<V>, V>>();

#[cfg(feature = "std")]
fn assert<T: Clone + Send + Sync + ::stdlib::hash::Hash>() {}
#[cfg(not(feature = "std"))]
fn assert<T: Clone + Send + Sync>() {}
}
}
}

0 comments on commit 9534c02

Please sign in to comment.