Improve concatenate! to support usage outside braces

Fixes #12.
This commit is contained in:
Vinzent Steinberg 2019-04-25 13:51:33 +02:00
parent 4e6082533c
commit c10616c46e
2 changed files with 4 additions and 6 deletions

View File

@ -98,7 +98,7 @@ macro_rules! assert_almost_eq {
#[macro_export] #[macro_export]
macro_rules! concatenate { macro_rules! concatenate {
( $name:ident, $([$estimator:ident, $statistic:ident]),+ ) => { ( $name:ident, $([$estimator:ident, $statistic:ident]),+ ) => {
concatenate!( $name, $([$estimator, $statistic, $statistic]),* ) concatenate!( $name, $([$estimator, $statistic, $statistic]),* );
}; };
( $name:ident, $( [$estimator:ident, $field:ident, $($statistic:ident),+] ),+ ) => { ( $name:ident, $( [$estimator:ident, $field:ident, $($statistic:ident),+] ),+ ) => {
struct $name { struct $name {

View File

@ -4,14 +4,12 @@
extern crate core; extern crate core;
use average::Estimate; use average::{Estimate, Min, Max};
#[test]
fn concatenate_simple() {
use average::{Min, Max};
concatenate!(MinMax, [Min, min], [Max, max]); concatenate!(MinMax, [Min, min], [Max, max]);
#[test]
fn concatenate_simple() {
{ {
let mut s = MinMax::new(); let mut s = MinMax::new();
for i in 1..6 { for i in 1..6 {