&mut self,
format: &Option<Format>,
string_format: &Option<StringFormat>,
- ) -> (crate::format::Format, Vec<Affix>) {
- let (format, affixes, relabels, try_strings_as_numbers) = if let Some(format) = &format {
+ ) -> crate::format::Format {
+ let (format, relabels, try_strings_as_numbers) = if let Some(format) = &format {
(
Some(format.decode()),
- format.affixes.clone(),
format.relabels.as_slice(),
format.try_strings_as_numbers.unwrap_or_default(),
)
} else if let Some(string_format) = &string_format {
- (
- None,
- string_format.affixes.clone(),
- string_format.relabels.as_slice(),
- false,
- )
+ (None, string_format.relabels.as_slice(), false)
} else {
- (None, Vec::new(), [].as_slice(), false)
+ (None, [].as_slice(), false)
};
for relabel in relabels {
let value = if try_strings_as_numbers && let Ok(to) = relabel.to.trim().parse::<f64>() {
};
self.0.insert(OrderedFloat(relabel.from), value);
}
- (format.unwrap_or(F8_0), affixes)
+ format.unwrap_or(F8_0)
}
fn apply(&self, data: &mut Vec<DataValue>) {
}
impl SourceVariable {
+ fn affixes(&self) -> &[Affix] {
+ if let Some(format) = &self.format {
+ &format.affixes
+ } else if let Some(string_format) = &self.string_format {
+ &string_format.affixes
+ } else {
+ &[]
+ }
+ }
fn decode<'a>(
&'a self,
data: &IndexMap<String, IndexMap<String, Vec<DataValue>>>,
{
values.as_slice()
} else {
- /*
- XXX warn
- */
&[]
};
let mut map = Map::new();
- let (format, affixes) = map.remap_formats(&self.format, &self.string_format);
+ let format = map.remap_formats(&self.format, &self.string_format);
let mut data = Vec::from(data);
if !map.0.is_empty() {
map.apply(&mut data);
series.insert(
&self.id,
Series::new(self.id.clone(), data, map)
- .with_affixes(affixes)
+ .with_affixes(Vec::from(self.affixes()))
.with_label(self.label.clone()),
);
true