Add support for Option<&T> in imported argument lists

Closes #619
This commit is contained in:
Alex Crichton
2018-08-02 22:28:13 -07:00
parent fe51cf9857
commit 88db12669f
2 changed files with 15 additions and 5 deletions

View File

@ -125,6 +125,10 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
self.cx.expose_take_object();
self.js_arguments.push(format!("takeObject({})", abi));
return Ok(())
} else if arg.is_ref_anyref() {
self.cx.expose_get_object();
self.js_arguments.push(format!("getObject({})", abi));
return Ok(())
}
if optional {
@ -253,10 +257,6 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
ref d if d.is_number() => abi,
Descriptor::Boolean => format!("{} !== 0", abi),
Descriptor::Char => format!("String.fromCodePoint({})", abi),
ref d if d.is_ref_anyref() => {
self.cx.expose_get_object();
format!("getObject({})", abi)
}
_ => bail!(
"unimplemented argument type in imported function: {:?}",
arg