/// Category index, if any. This is the numeric value of the datum, if
/// there is one, falling back to the index.
pub fn category(&self) -> Option<usize> {
- match &self.value {
- Datum::Number(number) => *number,
- _ if self.index.is_some() => self.index,
- Datum::String(string) => {
- // This only comes up in a few cases which indicate something
- // odd might have happened to the table in the SPV files.
- string.parse().ok()
- }
- }
- .and_then(|v| (v >= 0.0 && v < usize::MAX as f64).then_some(v as usize))
+ self.index
+ .and_then(|v| (v >= 0.0 && v < usize::MAX as f64).then_some(v as usize))
}
/// Interprets this data value as a [Format], first by looking it up in