File: noderive.rs

package info (click to toggle)
rust-blanket 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 548 kB
  • sloc: makefile: 2
file content (28 lines) | stat: -rw-r--r-- 534 bytes parent folder | download
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));
}