proxmox-metrics: send_data_to_channels: change from slice to IntoIterator

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@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Dominik Csapak 2022-06-10 13:17:50 +02:00 committed by Wolfgang Bumiller
parent 7667e549a5
commit e12230d543

View File

@ -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 {