Skip to content

Commit 165999f

Browse files
committed
codegen/parameter: Do not pass ByRef::None as reference
1 parent 41c35b0 commit 165999f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/codegen/parameter.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ pub trait ToParameter {
1616

1717
impl ToParameter for CParameter {
1818
fn to_parameter(&self, env: &Env, bounds: &Bounds) -> String {
19-
let mut_str = if self.ref_mode == RefMode::ByRefMut {
20-
"mut "
21-
} else {
22-
""
19+
let ref_str = match self.ref_mode {
20+
RefMode::ByRefMut => "&mut ",
21+
RefMode::None => "",
22+
_ => "&",
2323
};
2424
if self.instance_parameter {
25-
format!("&{}self", mut_str)
25+
format!("{}self", ref_str)
2626
} else {
2727
let type_str: String;
2828
match bounds.get_parameter_alias_info(&self.name) {
2929
Some((t, bound_type)) => match bound_type {
3030
BoundType::NoWrapper => type_str = t.to_string(),
3131
BoundType::IsA(_) if *self.nullable => {
32-
type_str = format!("Option<&{}{}>", mut_str, t)
32+
type_str = format!("Option<{}{}>", ref_str, t)
3333
}
34-
BoundType::IsA(_) => type_str = format!("&{}{}", mut_str, t),
34+
BoundType::IsA(_) => type_str = format!("{}{}", ref_str, t),
3535
BoundType::AsRef(_) => type_str = t.to_string(),
3636
},
3737
None => {

0 commit comments

Comments
 (0)