use std::error::Error;
use std::fmt::Debug;
use std::fs::{self, File};
-use std::io::Write;
+use std::io::{BufWriter, Write};
use std::path::Path;
#[derive(Copy, Clone, Debug)]
T: FactRow,
{
let file = &self.dir.join(file_name);
- let mut file = File::create(file)?;
+ let mut file = BufWriter::new(File::create(file)?);
for row in rows {
row.write(&mut file, self.location_table)?;
}
}
trait FactRow {
- fn write(&self, out: &mut File, location_table: &LocationTable) -> Result<(), Box<dyn Error>>;
+ fn write(
+ &self,
+ out: &mut dyn Write,
+ location_table: &LocationTable,
+ ) -> Result<(), Box<dyn Error>>;
}
impl FactRow for RegionVid {
- fn write(&self, out: &mut File, location_table: &LocationTable) -> Result<(), Box<dyn Error>> {
+ fn write(
+ &self,
+ out: &mut dyn Write,
+ location_table: &LocationTable,
+ ) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[self])
}
}
A: FactCell,
B: FactCell,
{
- fn write(&self, out: &mut File, location_table: &LocationTable) -> Result<(), Box<dyn Error>> {
+ fn write(
+ &self,
+ out: &mut dyn Write,
+ location_table: &LocationTable,
+ ) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[&self.0, &self.1])
}
}
B: FactCell,
C: FactCell,
{
- fn write(&self, out: &mut File, location_table: &LocationTable) -> Result<(), Box<dyn Error>> {
+ fn write(
+ &self,
+ out: &mut dyn Write,
+ location_table: &LocationTable,
+ ) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[&self.0, &self.1, &self.2])
}
}
C: FactCell,
D: FactCell,
{
- fn write(&self, out: &mut File, location_table: &LocationTable) -> Result<(), Box<dyn Error>> {
+ fn write(
+ &self,
+ out: &mut dyn Write,
+ location_table: &LocationTable,
+ ) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[&self.0, &self.1, &self.2, &self.3])
}
}