Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static-metric/src/builder: Allow non-public label enums #355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Oct 19, 2020

  1. static-metric/src/builder: Allow non-public label enums

    Imagine the following static metric generation:
    
    ```rust
    make_static_metric! {
        label_enum Methods {
            post,
            get,
        }
    
        struct MyStaticCounterVec: Counter {
            "method" => Methods,
        }
    }
    ```
    
    This will roughly expand to:
    
    ```rust
    enum Methods {
        post,
        get,
    }
    
    use self::prometheus_static_scope_0::MyStaticCounterVec;
    mod prometheus_static_scope_0 {
        pub struct MyStaticCounterVec {
            pub post: MyStaticCounterVec2,
            pub get: MyStaticCounterVec2,
        }
    }
    ```
    
    Rustc would complain that the `private type 'Methods' [is] in [the]
    public interface (error E0446)` `MyStaticCounterVec`.
    
    There is no reason for `MyStaticCounterVec` to be defined with
    visibility `pub`. This commit instead defines `MyStaticCounterVec` with
    `pub(super)` and thus `MyStaticCounterVec` does not expose the private
    type `Methods`.
    
    Signed-off-by: Max Inden <mail@max-inden.de>
    mxinden committed Oct 19, 2020
    Configuration menu
    Copy the full SHA
    bd6b513 View commit details
    Browse the repository at this point in the history