mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-24 08:09:16 -05:00
Rename String::new_empty() to String::empty() (#244)
This is more consistent with the C++ API.
This commit is contained in:
parent
8617f77fd3
commit
2286052468
2 changed files with 3 additions and 3 deletions
|
@ -63,7 +63,7 @@ bitflags! {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl String {
|
impl String {
|
||||||
pub fn new_empty<'sc>(scope: &mut impl ToLocal<'sc>) -> Local<'sc, String> {
|
pub fn empty<'sc>(scope: &mut impl ToLocal<'sc>) -> Local<'sc, String> {
|
||||||
let ptr = unsafe { v8__String__Empty(scope.isolate()) };
|
let ptr = unsafe { v8__String__Empty(scope.isolate()) };
|
||||||
// FIXME(bnoordhuis) v8__String__Empty() is infallible so there
|
// FIXME(bnoordhuis) v8__String__Empty() is infallible so there
|
||||||
// is no need to box up the result, only to unwrap it again.
|
// is no need to box up the result, only to unwrap it again.
|
||||||
|
@ -76,7 +76,7 @@ impl String {
|
||||||
new_type: NewStringType,
|
new_type: NewStringType,
|
||||||
) -> Option<Local<'sc, String>> {
|
) -> Option<Local<'sc, String>> {
|
||||||
if buffer.is_empty() {
|
if buffer.is_empty() {
|
||||||
return Some(Self::new_empty(scope));
|
return Some(Self::empty(scope));
|
||||||
}
|
}
|
||||||
let ptr = unsafe {
|
let ptr = unsafe {
|
||||||
v8__String__NewFromUtf8(
|
v8__String__NewFromUtf8(
|
||||||
|
|
|
@ -152,7 +152,7 @@ fn test_string() {
|
||||||
{
|
{
|
||||||
let mut hs = v8::HandleScope::new(scope);
|
let mut hs = v8::HandleScope::new(scope);
|
||||||
let scope = hs.enter();
|
let scope = hs.enter();
|
||||||
let local = v8::String::new_empty(scope);
|
let local = v8::String::empty(scope);
|
||||||
assert_eq!(0, local.length());
|
assert_eq!(0, local.length());
|
||||||
assert_eq!(0, local.utf8_length(scope));
|
assert_eq!(0, local.utf8_length(scope));
|
||||||
assert_eq!("", local.to_rust_string_lossy(scope));
|
assert_eq!("", local.to_rust_string_lossy(scope));
|
||||||
|
|
Loading…
Reference in a new issue