Okay this compiles

The secret (from #rust) appeared to be that Fn() needed to have + Send
explicitly annotated on it
This commit is contained in:
greg 2017-10-29 03:16:08 -07:00
parent ffb87ebb82
commit 1d9d0c4395
2 changed files with 6 additions and 2 deletions

View File

@ -38,7 +38,7 @@ include!(concat!(env!("OUT_DIR"), "/static.rs"));
#[link_args="-ltinfo"] #[link_args="-ltinfo"]
extern { } extern { }
type PLIGenerator = Box<Fn() -> Box<ProgrammingLanguageInterface>>; type PLIGenerator = Box<Fn() -> Box<ProgrammingLanguageInterface> + Send>;
fn main() { fn main() {
let languages: Vec<Box<ProgrammingLanguageInterface>> = let languages: Vec<Box<ProgrammingLanguageInterface>> =

View File

@ -1,4 +1,5 @@
use rocket; use rocket;
use rocket::State;
use rocket::response::Content; use rocket::response::Content;
use rocket::http::ContentType; use rocket::http::ContentType;
use rocket_contrib::Json; use rocket_contrib::Json;
@ -6,6 +7,7 @@ use schala_lang;
use language::{ProgrammingLanguageInterface, EvalOptions}; use language::{ProgrammingLanguageInterface, EvalOptions};
use WEBFILES; use WEBFILES;
use ::PLIGenerator; use ::PLIGenerator;
use std::sync::Mutex;
#[get("/")] #[get("/")]
fn index() -> Content<String> { fn index() -> Content<String> {
@ -39,5 +41,7 @@ fn interpreter_input(input: Json<Input>) -> Json<Output> {
} }
pub fn web_main(language_generators: Vec<Box<ProgrammingLanguageInterface>>, func: PLIGenerator) { pub fn web_main(language_generators: Vec<Box<ProgrammingLanguageInterface>>, 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();
} }