mirror of
https://github.com/132nd-vWing/tacview-splitter.git
synced 2026-08-26 07:48:37 +02:00
add blanket implementation for StringWriter
This commit is contained in:
+16
-14
@@ -48,10 +48,23 @@ fn create_zipwriter(outer_name: &str, inner_name: &str) -> Result<ZipWriter<File
|
|||||||
Ok(writer)
|
Ok(writer)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait StringWriter {
|
pub trait StringWriter
|
||||||
fn write_line<S: AsRef<str>>(&mut self, line: &S) -> Result<()>;
|
where
|
||||||
|
Self: Write,
|
||||||
|
{
|
||||||
|
fn write_line<S>(&mut self, line: &S) -> Result<()>
|
||||||
|
where
|
||||||
|
S: AsRef<str>,
|
||||||
|
{
|
||||||
|
writeln!(self, "{}", line.as_ref()).with_context(|| "could not write line")
|
||||||
|
}
|
||||||
|
|
||||||
fn write_strings<S: AsRef<str>>(&mut self, lines: &[S]) -> Result<()>;
|
fn write_strings<S: AsRef<str>>(&mut self, lines: &[S]) -> Result<()> {
|
||||||
|
for line in lines {
|
||||||
|
self.write_line(line)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn write_for_coalition<S: AsRef<str>>(
|
fn write_for_coalition<S: AsRef<str>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
@@ -65,17 +78,6 @@ impl<T> StringWriter for T
|
|||||||
where
|
where
|
||||||
T: Write,
|
T: Write,
|
||||||
{
|
{
|
||||||
fn write_line<S: AsRef<str>>(&mut self, line: &S) -> Result<()> {
|
|
||||||
writeln!(self, "{}", line.as_ref()).with_context(|| "could not write line")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write_strings<S: AsRef<str>>(&mut self, lines: &[S]) -> Result<()> {
|
|
||||||
for line in lines {
|
|
||||||
self.write_line(line)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write_for_coalition<S: AsRef<str>>(
|
fn write_for_coalition<S: AsRef<str>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
lines: &[S],
|
lines: &[S],
|
||||||
|
|||||||
Reference in New Issue
Block a user