From 2286052468c025644a7310ae4dea3ff82a7902da Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Wed, 22 Jan 2020 23:21:56 +0100 Subject: [PATCH] Rename String::new_empty() to String::empty() (#244) This is more consistent with the C++ API. --- src/string.rs | 4 ++-- tests/test_api.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/string.rs b/src/string.rs index 811d3432..2a5fee12 100644 --- a/src/string.rs +++ b/src/string.rs @@ -63,7 +63,7 @@ bitflags! { } 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()) }; // FIXME(bnoordhuis) v8__String__Empty() is infallible so there // is no need to box up the result, only to unwrap it again. @@ -76,7 +76,7 @@ impl String { new_type: NewStringType, ) -> Option> { if buffer.is_empty() { - return Some(Self::new_empty(scope)); + return Some(Self::empty(scope)); } let ptr = unsafe { v8__String__NewFromUtf8( diff --git a/tests/test_api.rs b/tests/test_api.rs index c0febe08..1885ec79 100644 --- a/tests/test_api.rs +++ b/tests/test_api.rs @@ -152,7 +152,7 @@ fn test_string() { { let mut hs = v8::HandleScope::new(scope); 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.utf8_length(scope)); assert_eq!("", local.to_rust_string_lossy(scope));