Merge pull request #412 from napi-rs/remove-string-ref

fix(napi): remove into_*_ref from JsString
This commit is contained in:
LongYinan 2021-01-07 13:14:05 +08:00 committed by GitHub
commit 8f9a77fd38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 20 deletions

View file

@ -4,8 +4,7 @@ use std::os::raw::c_void;
use std::ptr;
use std::slice;
use super::{Value, ValueType};
use crate::{check_status, sys, JsUnknown, NapiValue, Ref, Result};
use crate::{check_status, sys, JsUnknown, NapiValue, Ref, Result, Value, ValueType};
pub struct JsArrayBuffer(pub(crate) Value);

View file

@ -4,6 +4,7 @@ use std::ptr;
use super::*;
use crate::{check_status, sys, Result};
#[derive(Clone, Copy)]
pub struct JsBigint {
pub(crate) raw: Value,
pub word_count: usize,

View file

@ -4,6 +4,7 @@ use super::Value;
use crate::check_status;
use crate::{sys, Error, Result};
#[derive(Clone, Copy)]
pub struct JsBoolean(pub(crate) Value);
impl JsBoolean {

View file

@ -61,8 +61,10 @@ pub use value_type::ValueType;
pub struct JsUnknown(pub(crate) Value);
#[derive(Clone, Copy)]
pub struct JsNull(pub(crate) Value);
#[derive(Clone, Copy)]
pub struct JsSymbol(pub(crate) Value);
pub struct JsExternal(pub(crate) Value);

View file

@ -4,6 +4,7 @@ use super::Value;
use crate::check_status;
use crate::{sys, Error, Result};
#[derive(Clone, Copy)]
pub struct JsNumber(pub(crate) Value);
impl JsNumber {

View file

@ -1,9 +1,7 @@
use std::mem;
use std::ptr;
use super::Value;
use crate::check_status;
use crate::{sys, Ref, Result};
use crate::{check_status, sys, Result, Value};
pub use latin1::JsStringLatin1;
pub use utf16::JsStringUtf16;
@ -70,11 +68,6 @@ impl JsString {
})
}
#[inline]
pub fn into_utf8_ref(self) -> Result<Ref<JsStringUtf8>> {
Ref::new(self.0, 1, self.into_utf8()?)
}
#[inline]
pub fn into_utf16(self) -> Result<JsStringUtf16> {
let mut written_char_count = 0usize;
@ -100,11 +93,6 @@ impl JsString {
})
}
#[inline]
pub fn into_utf16_ref(self) -> Result<Ref<JsStringUtf16>> {
Ref::new(self.0, 1, self.into_utf16()?)
}
#[inline]
pub fn into_latin1(self) -> Result<JsStringLatin1> {
let mut written_char_count = 0usize;
@ -130,9 +118,4 @@ impl JsString {
}),
})
}
#[inline]
pub fn into_latin1_ref(self) -> Result<Ref<JsStringLatin1>> {
Ref::new(self.0, 1, self.into_latin1()?)
}
}

View file

@ -1,3 +1,4 @@
use super::Value;
#[derive(Clone, Copy)]
pub struct JsUndefined(pub(crate) Value);