Skip to content

Instantly share code, notes, and snippets.

@linclark
Created November 9, 2016 18:58
Show Gist options
  • Save linclark/7fef9e4682451858192615473b81d555 to your computer and use it in GitHub Desktop.
Save linclark/7fef9e4682451858192615473b81d555 to your computer and use it in GitHub Desktop.
#![feature(link_args)]
#[link_args = "-s EXPORTED_FUNCTIONS=['_hello_world']"]
extern {}
extern crate semver;
use semver::Version;
use semver::VersionReq;
#[no_mangle]
pub fn hello_world() -> bool {
// let r = VersionReq::parse(">= 1.0.0").unwrap();
// let v = Version::parse("1.0.0").unwrap();
true
}
fn main() {
/* Intentionally left blank */
}
var Module = require("./main.js");
var hello_world = Module.cwrap('hello_world', 'boolean', []);
var result = hello_world();
console.log("result: ", result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment