Removed unnecessary option return type

This commit is contained in:
2026-05-04 17:14:17 +02:00
parent 32a08d3e7f
commit 7b1d2e3d91
3 changed files with 9 additions and 8 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ pub enum TopLevel {
export: bool, export: bool,
name: String, name: String,
params: ParamList, params: ParamList,
return_type: Option<TypeExpr>, return_type: TypeExpr,
body: Block, body: Block,
}, },
} }
+1 -1
View File
@@ -100,7 +100,7 @@ impl TryFrom<pest::iterators::Pair<'_, Rule>> for TopLevel {
false false
}; };
let return_type = Some(TypeExpr::from(inner.next().unwrap())); let return_type = TypeExpr::from(inner.next().unwrap());
let name = inner.next().unwrap().as_str().to_string(); let name = inner.next().unwrap().as_str().to_string();
let params = if inner.peek().unwrap().as_rule() == Rule::param_list { let params = if inner.peek().unwrap().as_rule() == Rule::param_list {
+7 -6
View File
@@ -217,12 +217,13 @@ impl ToRust for TopLevel {
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join(", "); .join(", ");
let ret = return_type cg.addln(&format!(
.as_ref() "{}fn {}({}) -> {} {{",
.map(|t| format!(" -> {}", t.get_rust())) vis,
.unwrap_or_default(); name,
params_str,
cg.addln(&format!("{}fn {}({}){} {{", vis, name, params_str, ret)); return_type.get_rust()
));
cg.indent += 1; cg.indent += 1;
body.to_rust(cg); body.to_rust(cg);
cg.indent -= 1; cg.indent -= 1;