Skip to content

Commit

Permalink
Support visibility to concatenate macro
Browse files Browse the repository at this point in the history
  • Loading branch information
hatoo authored and vks committed Apr 26, 2024
1 parent 2a8cb8c commit ca4859e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ macro_rules! assert_almost_eq {
/// ```
#[macro_export]
macro_rules! concatenate {
( $name:ident, $([$estimator:ident, $statistic:ident]),+ ) => {
concatenate!( $name, $([$estimator, $statistic, $statistic]),* );
( $visibility:vis $name:ident, $([$estimator:ident, $statistic:ident]),+ ) => {
concatenate!($visibility $name, $([$estimator, $statistic, $statistic]),* );
};
( $name:ident, $( [$estimator:ident, $field:ident, $($statistic:ident),+] ),+ ) => {
struct $name {
( $visibility:vis $name:ident, $( [$estimator:ident, $field:ident, $($statistic:ident),+] ),+ ) => {
$visibility struct $name {
$(
$field: $estimator,
)*
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use average::{concatenate, Estimate, Max, Min};

concatenate!(MinMax, [Min, min], [Max, max]);
concatenate!(pub MinMax, [Min, min], [Max, max]);

#[test]
fn concatenate_simple() {
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ mod skewness;
mod streaming_stats;
mod weighted_mean;
mod covariance;

// Ensure that the struct defined by macro is accessible
#[allow(unused_imports)]
use macros::MinMax;

0 comments on commit ca4859e

Please sign in to comment.