0
0
Fork 0
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:
Bert Belder 2020-01-22 23:21:56 +01:00
parent 8617f77fd3
commit 2286052468
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461
2 changed files with 3 additions and 3 deletions

View file

@ -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(

View file

@ -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));