-use std::{borrow::Cow, fmt::Display, fs::File, io::Write, sync::Arc};
+use std::{borrow::Cow, fmt::Display, fs::File, io::{Error, Write}, sync::Arc};
use crate::output::pivot::Coord2;
self.n_items += 1;
}
- fn output_table_layer(&mut self, pt: &PivotTable, layer: &[usize]) -> Result<(), csv::Error> {
+ fn output_table_layer(&mut self, pt: &PivotTable, layer: &[usize]) -> Result<(), Error> {
let output = pt.output(layer, true);
self.start_item();
pivot_table: &PivotTable,
table: Option<&Table>,
leader: Option<&str>,
- ) -> Result<(), csv::Error> {
+ ) -> Result<(), Error> {
let Some(table) = table else {
return Ok(());
};
for y in 0..table.n.y() {
for x in 0..table.n.x() {
if x > 0 {
- write!(&mut self.file, "{}", self.options.delimiter as char).unwrap();
+ write!(&mut self.file, "{}", self.options.delimiter as char)?;
}
let coord = Coord2::new(x, y);
Some(leader) if x == 0 && y == 0 => format!("{leader}: {display}"),
_ => display.to_string(),
};
- write!(&mut self.file, "{}", CsvField::new(&s, self.options)).unwrap();
+ write!(&mut self.file, "{}", CsvField::new(&s, self.options))?;
}
}
}
- writeln!(&mut self.file).unwrap();
+ writeln!(&mut self.file)?;
}
Ok(())
#[derive(Clone, Debug, Default)]
pub struct Axis {
/// `dimensions[0]` is the innermost dimension.
- dimensions: Vec<Dimension>,
+ dimensions: Vec<Arc<Dimension>>,
/// The number of rows or columns along the axis, that is, the product of
/// `dimensions[*].len()`. It is 0 if any dimension has 0 leaves.
corner_text: Option<Value>,
caption: Option<Value>,
notes: Option<String>,
- dimensions: Vec<Dimension>,
+ dimensions: Vec<Arc<Dimension>>,
axes: EnumMap<Axis3, Axis>,
cells: HashMap<usize, Value>,
}