append inline always

This commit is contained in:
Numbers
2025-06-03 00:59:41 +02:00
parent d5ff54d4b5
commit 4dbb37cedc

View File

@@ -25,9 +25,11 @@ fn derive_struct(name: Ident, data: &DataStruct) -> Result<TokenStream, std::fmt
writeln!(&mut output, "#[automatically_derived]")?; writeln!(&mut output, "#[automatically_derived]")?;
writeln!(&mut output, "impl otw::OverTheWire for {name} {{")?; writeln!(&mut output, "impl otw::OverTheWire for {name} {{")?;
writeln!(&mut output, " #[inline(always)]")?;
writeln!(&mut output, " fn serialize<T: otw::Writer>(&self, writer: &mut T) -> e::Result<()> {{")?; writeln!(&mut output, " fn serialize<T: otw::Writer>(&self, writer: &mut T) -> e::Result<()> {{")?;
wsf(&mut output, " ", Some("self"), &data.fields)?; wsf(&mut output, " ", Some("self"), &data.fields)?;
writeln!(&mut output, " }}")?; writeln!(&mut output, " }}")?;
writeln!(&mut output, " #[inline(always)]")?;
writeln!(&mut output, " fn deserialize<T: otw::Reader>(reader: &mut T) -> e::Result<Self> {{")?; writeln!(&mut output, " fn deserialize<T: otw::Reader>(reader: &mut T) -> e::Result<Self> {{")?;
wdf(&mut output, " ", tname.as_str(), &data.fields)?; wdf(&mut output, " ", tname.as_str(), &data.fields)?;
writeln!(&mut output, " }}")?; writeln!(&mut output, " }}")?;
@@ -47,6 +49,7 @@ fn derive_enum(name: Ident, data: &DataEnum) -> Result<TokenStream, std::fmt::Er
writeln!(&mut output, "#[automatically_derived]")?; writeln!(&mut output, "#[automatically_derived]")?;
writeln!(&mut output, "impl otw::OverTheWire for {name} {{")?; writeln!(&mut output, "impl otw::OverTheWire for {name} {{")?;
writeln!(&mut output, " #[inline(always)]")?;
writeln!(&mut output, " fn serialize<T: otw::Writer>(&self, writer: &mut T) -> e::Result<()> {{")?; writeln!(&mut output, " fn serialize<T: otw::Writer>(&self, writer: &mut T) -> e::Result<()> {{")?;
writeln!(&mut output, " match self {{")?; writeln!(&mut output, " match self {{")?;
@@ -91,6 +94,7 @@ fn derive_enum(name: Ident, data: &DataEnum) -> Result<TokenStream, std::fmt::Er
writeln!(&mut output, " }}")?; writeln!(&mut output, " }}")?;
//╶───╴Deserialize╶──────────────────────────────────────────────────────────╴ //╶───╴Deserialize╶──────────────────────────────────────────────────────────╴
writeln!(&mut output, " #[inline(always)]")?;
writeln!(&mut output, " fn deserialize<T: otw::Reader>(reader: &mut T) -> e::Result<Self> {{")?; writeln!(&mut output, " fn deserialize<T: otw::Reader>(reader: &mut T) -> e::Result<Self> {{")?;
writeln!(&mut output, " match <u8 as otw::OverTheWire>::deserialize(reader)? {{")?; writeln!(&mut output, " match <u8 as otw::OverTheWire>::deserialize(reader)? {{")?;