From e381731475e6f5bc13c9cb2be4b3d70695ed1155 Mon Sep 17 00:00:00 2001 From: Alain Emilia Anna Zscheile Date: Thu, 5 Dec 2024 20:35:06 +0100 Subject: [PATCH] feat(specctra-core/write): get rid of unnecessary restrictions on method args --- crates/specctra-core/src/write.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/crates/specctra-core/src/write.rs b/crates/specctra-core/src/write.rs index 340be12..7b12302 100644 --- a/crates/specctra-core/src/write.rs +++ b/crates/specctra-core/src/write.rs @@ -26,10 +26,13 @@ impl WriteSes for String { impl WriteSes for bool { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), io::Error> { - writer.write_leaf(match self { - true => "on".to_string(), - false => "off".to_string(), - }) + writer.write_leaf( + match self { + true => "on", + false => "off", + } + .to_string(), + ) } } @@ -122,11 +125,7 @@ impl ListWriter { value.write_dsn(self) } - pub fn write_named>( - &mut self, - name: &'static str, - value: &T, - ) -> Result<(), io::Error> { + pub fn write_named>(&mut self, name: &str, value: &T) -> Result<(), io::Error> { self.write_token(ListToken::Start { name: name.to_string(), })?; @@ -138,7 +137,7 @@ impl ListWriter { pub fn write_optional>( &mut self, - name: &'static str, + name: &str, optional: &Option, ) -> Result<(), io::Error> { if let Some(value) = optional { @@ -148,7 +147,7 @@ impl ListWriter { Ok(()) } - pub fn write_array>(&mut self, array: &Vec) -> Result<(), io::Error> { + pub fn write_array>(&mut self, array: &[T]) -> Result<(), io::Error> { for elem in array { self.write_value(elem)?; } @@ -158,8 +157,8 @@ impl ListWriter { pub fn write_named_array>( &mut self, - name: &'static str, - array: &Vec, + name: &str, + array: &[T], ) -> Result<(), io::Error> { for elem in array { self.write_named(name, elem)?;