Skip to content

Commit

Permalink
pulling_gauge: fix build with --no-default-features (#473)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
tyranron authored Dec 22, 2022
1 parent 8b462b1 commit a7b8f09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
run: cargo build
- name: cargo test
run: cargo test
- name: cargo test (no default features)
run: cargo test --no-default-features
- name: cargo test (extra features)
run: cargo test --no-default-features --features="${{ env['EXTRA_FEATURES'] }}"
- name: cargo package
Expand Down Expand Up @@ -72,6 +74,8 @@ jobs:
default: true
- run: cargo build
- run: cargo test --no-run
- run: cargo build --no-default-features
- run: cargo test --no-default-features --no-run
- run: cargo build --no-default-features --features="${{ env['EXTRA_FEATURES'] }}"
- run: cargo test --no-default-features --features="${{ env['EXTRA_FEATURES'] }}"
linting:
Expand All @@ -90,6 +94,10 @@ jobs:
run: cargo fmt --all -- --check -l
- name: cargo clippy
run: cargo clippy --all
- name: cargo clippy (no default features)
run: cargo clippy --all --no-default-features
- name: cargo clippy (extra features)
run: cargo clippy --all --no-default-features --features="${{ env['EXTRA_FEATURES'] }}"
criterion:
name: "Benchmarks (criterion)"
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions src/pulling_gauge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
core::Collector,
proto::{Gauge, Metric, MetricFamily, MetricType},
};
use protobuf::RepeatedField;

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

0 comments on commit a7b8f09

Please sign in to comment.