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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#![feature(alloc)]
#![feature(allocator_api)]
#![feature(test)]
#![feature(const_fn)]
#![feature(plugin)]
#![plugin(interpolate_idents)]
#[cfg(unix)]
#[macro_use]
extern crate lazy_static;
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
#[allow(plugin_as_library)]
extern crate interpolate_idents;
pub use self::interpolate_idents::*;
pub mod corruption;
pub mod leaky_alloc;
pub mod types;
pub fn foreach_align<T, F: Fn(usize)>(f: F, max: usize) {
use std::mem::{size_of, align_of};
let min_align = align_of::<T>();
let size = size_of::<T>();
let mut align = min_align;
while align <= size && align <= max {
if size % align == 0 {
f(align);
}
align *= 2;
}
}