From b97da01370f3fea7463bff54d2ef840c6bb966b8 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 29 Oct 2017 12:27:24 -0700 Subject: [PATCH] Some simplification --- src/main.rs | 2 +- src/webapp.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 36772b3..ea4163f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,7 +77,7 @@ fn schala_main(languages: Vec>, generators: Ve } if option_matches.opt_present("webapp") { - webapp::web_main(languages, generators); + webapp::web_main(generators); exit(0); } diff --git a/src/webapp.rs b/src/webapp.rs index 1918f55..5d4975e 100644 --- a/src/webapp.rs +++ b/src/webapp.rs @@ -32,12 +32,13 @@ struct Output { } #[post("/input", format = "application/json", data = "")] -fn interpreter_input(input: Json, schala_gen: State>) -> Json { - let mut schala: Box = (schala_gen.get(0).unwrap())(); +fn interpreter_input(input: Json, generators: State>) -> Json { + let schala_gen = generators.get(0).unwrap(); + let mut schala: Box = schala_gen(); let code_output = schala.evaluate_in_repl(&input.source, &EvalOptions::default()); Json(Output { text: code_output.to_string() }) } -pub fn web_main(language_generators: Vec>, func: Vec) { - rocket::ignite().manage(func).mount("/", routes![index, js_bundle, interpreter_input]).launch(); +pub fn web_main(language_generators: Vec) { + rocket::ignite().manage(language_generators).mount("/", routes![index, js_bundle, interpreter_input]).launch(); }