rust-prometheus
rust-prometheus copied to clipboard
static-metric/src/builder: Allow non-public label enums
Imagine the following static metric generation:
make_static_metric! {
label_enum Methods {
post,
get,
}
struct MyStaticCounterVec: Counter {
"method" => Methods,
}
}
This will roughly expand to:
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 [email protected]
Maybe supplying some tests that will pass compile in this PR but will fail in master would be better!