Neon - Rust code in Node.js
$ npm install
-
g neon
-
cli
$ neon new my
-
project
fn make_an_array(mut cx: FunctionContext)
- >
JsResult {
/ /
Create some values:
let n = cx.number(9000);
let s = cx.string("hello");
let b = cx.boolean(true);
/ /
Create a new array:
let array: Handle = cx.empty_array();
/ /
Push the values into the array:
array.set(&mut cx, 0, n)?;
array.set(&mut cx, 1, s)?;
array.set(&mut cx, 2, b)?;
/ /
Return the array:
Ok(array)
}
register_module!(mut cx, {
cx.export_function("makeAnArray", make_an_array)
})
https:/
/github.com/neon-bindings/neon