| 1 | extern crate impls; |
| 2 | extern crate static_assertions; |
| 3 | |
| 4 | use std::rc::Rc; |
| 5 | use std::sync::atomic::AtomicU8; |
| 6 | use std::sync::atomic::Ordering; |
| 7 | |
| 8 | use impls::impls; |
| 9 | use static_assertions::const_assert; |
| 10 | |
| 11 | pub trait Counter { |
| 12 | fn increment(&self); |
| 13 | } |
| 14 | |
| 15 | #[derive(Default)] |
| 16 | struct AtomicCounter { |
| 17 | count: AtomicU8 |
| 18 | } |
| 19 | |
| 20 | impl Counter for AtomicCounter { |
| 21 | fn increment(&self) { |
| 22 | self.count.fetch_add(1, Ordering::SeqCst); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | fn main() { |
| 27 | const_assert!(impls!(AtomicCounter: Counter)); |
| 28 | const_assert!(impls!(Rc<AtomicCounter>: Counter)); |
| 29 | } |