From 99a5754c94901dedb65a2e29f1ddb37cf425d07a Mon Sep 17 00:00:00 2001 From: Matt Johnston <matt@ucc.asn.au> Date: Wed, 1 Jun 2022 19:53:22 +0800 Subject: [PATCH] Some tidying --- sshwire_derive/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sshwire_derive/src/lib.rs b/sshwire_derive/src/lib.rs index 01709f3..2d2ec45 100644 --- a/sshwire_derive/src/lib.rs +++ b/sshwire_derive/src/lib.rs @@ -230,7 +230,8 @@ fn encode_struct(gen: &mut Generator, body: StructBody) -> Result<()> { } _ => { - // empty + // other variants are only for enums + unreachable!() } } @@ -245,9 +246,6 @@ fn encode_enum( atts: &[Attribute], body: EnumBody, ) -> Result<()> { - // if body.variants.is_empty() { - // return Ok(()) - // } let cont_atts = take_cont_atts(atts)?; @@ -429,7 +427,8 @@ fn decode_struct(gen: &mut Generator, body: StructBody) -> Result<()> { })?; } _ => { - // empty + // other variants are only for enums + unreachable!() } } @@ -474,7 +473,7 @@ fn decode_enum_variant_prefix( .generate_fn("dec") .with_generic_deps("S", ["crate::sshwire::SSHSource<'de>"]) .with_arg("s", "&mut S") - .with_return_type(format!("Result<Self>")) + .with_return_type("Result<Self>") .body(|fn_body| { fn_body .push_parsed("let variant = crate::sshwire::SSHDecode::dec(s)?;")?; @@ -495,7 +494,7 @@ fn decode_enum_names( .with_generic_deps("S", ["crate::sshwire::SSHSource<'de>"]) .with_arg("s", "&mut S") .with_arg("variant", "&'de str") - .with_return_type(format!("Result<Self>")) + .with_return_type("Result<Self>") .body(|fn_body| { fn_body.push_parsed("let r = match variant")?; fn_body.group(Delimiter::Brace, |match_arm| { -- GitLab