From 165999fdd25bc572606975821b0fdb19a9838cdc Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sun, 15 Nov 2020 18:03:38 +0100 Subject: [PATCH] codegen/parameter: Do not pass ByRef::None as reference --- src/codegen/parameter.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/codegen/parameter.rs b/src/codegen/parameter.rs index 2744b157e..a1506ef8a 100644 --- a/src/codegen/parameter.rs +++ b/src/codegen/parameter.rs @@ -16,22 +16,22 @@ pub trait ToParameter { impl ToParameter for CParameter { fn to_parameter(&self, env: &Env, bounds: &Bounds) -> String { - let mut_str = if self.ref_mode == RefMode::ByRefMut { - "mut " - } else { - "" + let ref_str = match self.ref_mode { + RefMode::ByRefMut => "&mut ", + RefMode::None => "", + _ => "&", }; if self.instance_parameter { - format!("&{}self", mut_str) + format!("{}self", ref_str) } else { let type_str: String; match bounds.get_parameter_alias_info(&self.name) { Some((t, bound_type)) => match bound_type { BoundType::NoWrapper => type_str = t.to_string(), BoundType::IsA(_) if *self.nullable => { - type_str = format!("Option<&{}{}>", mut_str, t) + type_str = format!("Option<{}{}>", ref_str, t) } - BoundType::IsA(_) => type_str = format!("&{}{}", mut_str, t), + BoundType::IsA(_) => type_str = format!("{}{}", ref_str, t), BoundType::AsRef(_) => type_str = t.to_string(), }, None => {