From 21751a4505f6647943f8751d4bda499d3aaef731 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Thu, 12 Apr 2018 22:32:30 +0200 Subject: [PATCH] fix warnings with rust 1.25.0 --- ofborg/build.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ofborg/build.rs b/ofborg/build.rs index 4881c36..58ca368 100644 --- a/ofborg/build.rs +++ b/ofborg/build.rs @@ -518,24 +518,27 @@ impl MetricCollector { .map(|mtype| { let fields: Vec = mtype.enum_field_names(); - let variant_match: String; - if fields.len() > 0 { - variant_match = format!("{}({})", &mtype.variant(), fields.join(", ")); + let variant_match = if fields.len() > 0 { + format!("{}({})", &mtype.variant(), fields.join(", ")) } else { - variant_match = format!("{}", &mtype.variant()); + format!("{}", &mtype.variant()) + }; + + let mut index_names: Vec = mtype.enum_index_names(); + index_names.push("instance".to_owned()); + + let mut index_fields = index_names.join(", "); + if index_names.len() > 1 { + index_fields = format!("({})", index_fields); } - let mut index_fields: Vec = mtype.enum_index_names(); - index_fields.push("instance".to_owned()); - - format!(" Event::{} => {{ let mut accum_table = self.{} .lock() .expect(\"Failed to unwrap metric mutex for {}\"); let accum = accum_table - .entry(({})) + .entry({}) .or_insert(0); *accum += {}; }} @@ -543,7 +546,7 @@ impl MetricCollector { variant_match, &mtype.metric_name(), &mtype.metric_name(), - index_fields.join(", "), + index_fields, &mtype.record_value(), ) }).collect();