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