From 6e8f57e54f1eb9d16dbb7d75d20da6c15353e8a8 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 29 Oct 2017 03:16:08 -0700 Subject: [PATCH] Okay this compiles The secret (from #rust) appeared to be that Fn() needed to have + Send explicitly annotated on it --- src/main.rs | 2 +- src/webapp.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 10f9cdd..198644f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,7 @@ include!(concat!(env!("OUT_DIR"), "/static.rs")); #[link_args="-ltinfo"] extern { } -type PLIGenerator = Box Box>; +type PLIGenerator = Box Box + Send>; fn main() { let languages: Vec> = diff --git a/src/webapp.rs b/src/webapp.rs index 70c259f..a0f706d 100644 --- a/src/webapp.rs +++ b/src/webapp.rs @@ -1,4 +1,5 @@ use rocket; +use rocket::State; use rocket::response::Content; use rocket::http::ContentType; use rocket_contrib::Json; @@ -6,6 +7,7 @@ use schala_lang; use language::{ProgrammingLanguageInterface, EvalOptions}; use WEBFILES; use ::PLIGenerator; +use std::sync::Mutex; #[get("/")] fn index() -> Content { @@ -39,5 +41,7 @@ fn interpreter_input(input: Json) -> Json { } pub fn web_main(language_generators: Vec>, func: PLIGenerator) { - rocket::ignite().mount("/", routes![index, js_bundle, interpreter_input]).launch(); + let wrapped_func = Mutex::new(func); + //let wrapped_func = Box::new(|| { 5 }); + rocket::ignite().manage(wrapped_func).mount("/", routes![index, js_bundle, interpreter_input]).launch(); }