Skip to content

Commit a7b8f09

Browse files
authored
pulling_gauge: fix build with --no-default-features (#473)
* Add CI checks for `--no-default-features` Signed-off-by: tyranron <[email protected]> * Fix broken compilation Signed-off-by: tyranron <[email protected]> Signed-off-by: tyranron <[email protected]>
1 parent 8b462b1 commit a7b8f09

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.github/workflows/rust.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
run: cargo build
3131
- name: cargo test
3232
run: cargo test
33+
- name: cargo test (no default features)
34+
run: cargo test --no-default-features
3335
- name: cargo test (extra features)
3436
run: cargo test --no-default-features --features="${{ env['EXTRA_FEATURES'] }}"
3537
- name: cargo package
@@ -72,6 +74,8 @@ jobs:
7274
default: true
7375
- run: cargo build
7476
- run: cargo test --no-run
77+
- run: cargo build --no-default-features
78+
- run: cargo test --no-default-features --no-run
7579
- run: cargo build --no-default-features --features="${{ env['EXTRA_FEATURES'] }}"
7680
- run: cargo test --no-default-features --features="${{ env['EXTRA_FEATURES'] }}"
7781
linting:
@@ -90,6 +94,10 @@ jobs:
9094
run: cargo fmt --all -- --check -l
9195
- name: cargo clippy
9296
run: cargo clippy --all
97+
- name: cargo clippy (no default features)
98+
run: cargo clippy --all --no-default-features
99+
- name: cargo clippy (extra features)
100+
run: cargo clippy --all --no-default-features --features="${{ env['EXTRA_FEATURES'] }}"
93101
criterion:
94102
name: "Benchmarks (criterion)"
95103
runs-on: ubuntu-latest

src/pulling_gauge.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::{
44
core::Collector,
55
proto::{Gauge, Metric, MetricFamily, MetricType},
66
};
7-
use protobuf::RepeatedField;
87

98
/// A [Gauge] that returns the value from a provided function on every collect run.
109
///
@@ -76,7 +75,7 @@ impl Collector for PullingGauge {
7675
m.set_name(self.desc.fq_name.clone());
7776
m.set_help(self.desc.help.clone());
7877
m.set_field_type(MetricType::GAUGE);
79-
m.set_metric(RepeatedField::from_vec(vec![self.metric()]));
78+
m.set_metric(from_vec!(vec![self.metric()]));
8079
vec![m]
8180
}
8281
}

0 commit comments

Comments
 (0)