/// `format_map` and otherwise by interpreting it as a [Format] directly.
///
/// This should probably be a method on some hypothetical FormatMap.
- pub fn as_format(
- &self,
- format_map: &HashMap<i64, crate::format::Format>,
- ) -> crate::format::Format {
+ pub fn as_format(&self) -> crate::format::Format {
let f = match &self.value {
Datum::Number(Some(number)) => *number as i64,
Datum::Number(None) => 0,
Datum::String(s) => s.parse().unwrap_or_default(),
};
- match format_map.get(&f) {
- Some(format) => *format,
- None => decode_format(f as u32, &mut |_| () /*XXX*/),
- }
+ decode_format(f as u32, &mut |_| () /*XXX*/)
}
/// Returns this data value interpreted using `format`.
let mut data = HashMap::new();
let mut coords = Vec::with_capacity(dims.len());
- let (cell_formats, format_map) = graph.interval.labeling.decode_format_map(&series);
+ let cell_formats = graph.interval.labeling.decode_format_map(&series);
'outer: for (i, cell) in cell.values.iter().enumerate() {
coords.clear();
for dim in dims {
let format = if let Some(cell_formats) = &cell_formats
&& let Some(value) = cell_formats.values.get(i)
{
- value.as_format(&format_map)
+ value.as_format()
} else {
F40_2
};
}
impl Labeling {
- fn decode_format_map<'a>(
- &self,
- series: &'a BTreeMap<&str, Series>,
- ) -> (Option<&'a Series>, HashMap<i64, crate::format::Format>) {
- let mut map = HashMap::new();
+ fn decode_format_map<'a>(&self, series: &'a BTreeMap<&str, Series>) -> Option<&'a Series> {
let mut cell_format = None;
for child in &self.children {
if let LabelingChild::Formatting(formatting) = child {
cell_format = series.get(formatting.variable.as_str());
- for mapping in &formatting.mappings {
- if let Some(format) = &mapping.format {
- map.insert(mapping.from, format.decode());
- }
- }
}
}
- (cell_format, map)
+ cell_format
}
}