mirror of https://codeberg.org/topola/topola.git
feat(specctra-core/write): get rid of unnecessary restrictions on method args
This commit is contained in:
parent
acab24d7d4
commit
e381731475
|
|
@ -26,10 +26,13 @@ impl<W: io::Write> WriteSes<W> for String {
|
||||||
|
|
||||||
impl<W: io::Write> WriteSes<W> for bool {
|
impl<W: io::Write> WriteSes<W> for bool {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||||
writer.write_leaf(match self {
|
writer.write_leaf(
|
||||||
true => "on".to_string(),
|
match self {
|
||||||
false => "off".to_string(),
|
true => "on",
|
||||||
})
|
false => "off",
|
||||||
|
}
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,11 +125,7 @@ impl<W: io::Write> ListWriter<W> {
|
||||||
value.write_dsn(self)
|
value.write_dsn(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_named<T: WriteSes<W>>(
|
pub fn write_named<T: WriteSes<W>>(&mut self, name: &str, value: &T) -> Result<(), io::Error> {
|
||||||
&mut self,
|
|
||||||
name: &'static str,
|
|
||||||
value: &T,
|
|
||||||
) -> Result<(), io::Error> {
|
|
||||||
self.write_token(ListToken::Start {
|
self.write_token(ListToken::Start {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
})?;
|
})?;
|
||||||
|
|
@ -138,7 +137,7 @@ impl<W: io::Write> ListWriter<W> {
|
||||||
|
|
||||||
pub fn write_optional<T: WriteSes<W>>(
|
pub fn write_optional<T: WriteSes<W>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &'static str,
|
name: &str,
|
||||||
optional: &Option<T>,
|
optional: &Option<T>,
|
||||||
) -> Result<(), io::Error> {
|
) -> Result<(), io::Error> {
|
||||||
if let Some(value) = optional {
|
if let Some(value) = optional {
|
||||||
|
|
@ -148,7 +147,7 @@ impl<W: io::Write> ListWriter<W> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_array<T: WriteSes<W>>(&mut self, array: &Vec<T>) -> Result<(), io::Error> {
|
pub fn write_array<T: WriteSes<W>>(&mut self, array: &[T]) -> Result<(), io::Error> {
|
||||||
for elem in array {
|
for elem in array {
|
||||||
self.write_value(elem)?;
|
self.write_value(elem)?;
|
||||||
}
|
}
|
||||||
|
|
@ -158,8 +157,8 @@ impl<W: io::Write> ListWriter<W> {
|
||||||
|
|
||||||
pub fn write_named_array<T: WriteSes<W>>(
|
pub fn write_named_array<T: WriteSes<W>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &'static str,
|
name: &str,
|
||||||
array: &Vec<T>,
|
array: &[T],
|
||||||
) -> Result<(), io::Error> {
|
) -> Result<(), io::Error> {
|
||||||
for elem in array {
|
for elem in array {
|
||||||
self.write_named(name, elem)?;
|
self.write_named(name, elem)?;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue