From aed95dfd941d418faa1f816895e097fe867c2ac3 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 3 May 2014 15:04:25 +0200 Subject: Move the assignment outside the if when dealing with optional arguments. --- src/components/script/dom/bindings/codegen/CodegenRust.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/components/script/dom/bindings/codegen/CodegenRust.py') diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 327fa119c9f..7bb5663b026 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -824,6 +824,12 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements, string.Template(templateBody).substitute(replacements) ) + if argcAndIndex is not None: + condition = string.Template("${index} < ${argc}").substitute(argcAndIndex) + conversion = CGIfElseWrapper(condition, + conversion, + CGGeneric("None")) + if declType is not None: newDecl = [CGGeneric("let mut "), CGGeneric(replacements["declName"]), @@ -835,12 +841,6 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements, pre="%s = " % replacements["declName"], post=";") - if argcAndIndex is not None: - condition = string.Template("${index} < ${argc}").substitute(argcAndIndex) - conversion = CGIfElseWrapper(condition, - conversion, - CGGeneric("%s = None" % replacements["declName"])) - result.append(conversion) # Add an empty CGGeneric to get an extra newline after the argument # conversion. -- cgit v1.2.3