chore(napi): remove TryFrom<JsNumber> for usize
This commit is contained in:
parent
96b1abc00f
commit
cbd4e4d1fc
2 changed files with 2 additions and 13 deletions
|
@ -6,16 +6,6 @@ use crate::{sys, Error, Result};
|
|||
|
||||
pub struct JsNumber(pub(crate) Value);
|
||||
|
||||
impl TryFrom<JsNumber> for usize {
|
||||
type Error = Error;
|
||||
|
||||
fn try_from(value: JsNumber) -> Result<usize> {
|
||||
let mut result = 0;
|
||||
check_status!(unsafe { sys::napi_get_value_int64(value.0.env, value.0.value, &mut result) })?;
|
||||
Ok(result as usize)
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<JsNumber> for u32 {
|
||||
type Error = Error;
|
||||
|
||||
|
|
|
@ -12,9 +12,8 @@ fn test_create_array(env: Env) -> ContextlessResult<JsObject> {
|
|||
|
||||
#[js_function(1)]
|
||||
fn test_create_array_with_length(ctx: CallContext) -> Result<JsObject> {
|
||||
ctx
|
||||
.env
|
||||
.create_array_with_length(ctx.get::<JsNumber>(0)?.try_into()?)
|
||||
let length: u32 = ctx.get::<JsNumber>(0)?.try_into()?;
|
||||
ctx.env.create_array_with_length(length as usize)
|
||||
}
|
||||
|
||||
#[js_function(3)]
|
||||
|
|
Loading…
Reference in a new issue