[][src]Macro average::define_histogram

macro_rules! define_histogram {
    ($name:ident, $LEN:expr) => { ... };
}

Define a histogram with a number of bins known at compile time.

Because macros are not hygenic for items, everything is defined in a private module with the given name. This includes the Histogram struct, the number of bins LEN and the histogram iterator HistogramIter.

Note that you need to make sure that core is accessible to the macro.

Example

use average::Histogram;

define_histogram!(hist, 10);
let mut h = hist::Histogram::with_const_width(0., 100.);
for i in 0..100 {
    h.add(i as f64).unwrap();
}
assert_eq!(h.bins(), &[10, 10, 10, 10, 10, 10, 10, 10, 10, 10]);