Skip to content

Commit

Permalink
codegen/parameter: Do not pass ByRef::None as reference
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Nov 19, 2020
1 parent 41c35b0 commit 165999f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/codegen/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 165999f

Please sign in to comment.