[pbs-devel] [PATCH proxmox v9 1/1] proxmox-metrics: send_data_to_channels: change from slice to IntoIterator
Dominik Csapak
d.csapak at proxmox.com
Fri Jun 10 13:17:50 CEST 2022
which is a bit generic and allows us to use e.g. a map result to be
passed here
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
proxmox-metrics/src/lib.rs | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/proxmox-metrics/src/lib.rs b/proxmox-metrics/src/lib.rs
index a55f0af..000cb39 100644
--- a/proxmox-metrics/src/lib.rs
+++ b/proxmox-metrics/src/lib.rs
@@ -69,11 +69,12 @@ impl MetricsData {
}
/// Helper to send a list of [`MetricsData`] to a list of [`Metrics`].
-pub async fn send_data_to_channels(
+pub async fn send_data_to_channels<'a, I: IntoIterator<Item = &'a Metrics>>(
values: &[Arc<MetricsData>],
- connections: &[Metrics],
+ connections: I,
) -> Vec<Result<(), Error>> {
- let mut futures = Vec::with_capacity(connections.len());
+ let connections = connections.into_iter();
+ let mut futures = Vec::with_capacity(connections.size_hint().0);
for connection in connections {
futures.push(async move {
for data in values {
--
2.30.2
More information about the pbs-devel
mailing list