When running the following code:
Cargo.toml
[lib]
crate-type = ["cdylib"]
[dependencies]
serde = { version = "1.0", features = ["derive"] }
wasm-bindgen = {version = "0.2.67", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4.17"
lib.rs
use serde::{Deserialize, Serialize};
use wasm_bindgen::prelude::*;
#[derive(Serialize, Deserialize)]
struct Output {
strings: Vec<String>,
}
#[wasm_bindgen] //error occuring here
pub async fn return_strings(_input: &str) -> JsValue {
//example function that returns a js value
let strings: Vec<String> = Default::default();
let output = Output { strings };
JsValue::from_serde(&output).unwrap()
}
I get the following error:
*arg0
does not live long enough
borrowed value does not live long enoughargument requires that *arg0
is borrowed for 'static
If anyone could let me know why, I would be a huge help.