-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update examples for v1.0 #97
Conversation
@@ -9,3 +9,6 @@ members = [ | |||
|
|||
[profile.release] | |||
lto = true | |||
|
|||
[patch.crates-io] | |||
neon = { git = "https://github.com/neon-bindings/neon.git" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to delete this once 1.0
is published.
let data = guard.get_mut(); | ||
let output = data.clone(); | ||
let output = JsUint8Array::from_slice(&mut cx, data)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we were already cloning, we can get very similar ergonomics and performance by copying directly into the Uint8Array
instead of using an external
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvements!
@@ -135,7 +134,7 @@ impl Database { | |||
let name = cx.argument::<JsString>(0)?.value(&mut cx); | |||
|
|||
// Get the `this` value as a `JsBox<Database>` | |||
let db = cx.this().downcast_or_throw::<JsBox<Database>, _>(&mut cx)?; | |||
let db = cx.this::<JsBox<Database>>()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General specialization would be awesome here. We could have a blanket impl for downcasting T
, but a specialized case for when T
implements Value
.
This would allow you to skip the JsBox
here and assume it from an out param.
We can make some further improvements when the
args
API lands.