This commit is contained in:
2021-11-07 15:26:04 +01:00
commit 200946c642
68 changed files with 33325 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
use neon::prelude::*;
fn hello(mut cx: FunctionContext) -> JsResult<JsString> {
Ok(cx.string("hello from rust 🦀"))
}
struct MyStruct {
name: String,
}
impl MyStruct {
fn new(name: String) -> Self {
println!("NEW {}", &name);
Self { name }
}
}
impl Drop for MyStruct {
fn drop(&mut self) {
println!("DROP {}", self.name);
}
}
impl Finalize for MyStruct {
fn finalize<'a, C: Context<'a>>(self, _: &mut C) {
println!("FINALIZE {}", self.name);
}
}
fn test_box(mut cx: FunctionContext) -> JsResult<JsBox<MyStruct>> {
let my_struct = MyStruct::new("Test Struct ayayay".to_string());
Ok(cx.boxed(my_struct))
}
#[neon::main]
fn main(mut cx: ModuleContext) -> NeonResult<()> {
cx.export_function("hello", hello)?;
cx.export_function("gib_box", test_box)?;
Ok(())
}