0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2025-01-11 08:34:01 -05:00

Expose v8::WriteOptions (#583)

Without it, v8::String::write_utf8() is pretty much unusable.
This commit is contained in:
Ben Noordhuis 2021-01-13 00:49:59 +01:00 committed by GitHub
parent 584a037800
commit 5cb14847aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -127,6 +127,7 @@ pub use snapshot::FunctionCodeHandling;
pub use snapshot::SnapshotCreator;
pub use snapshot::StartupData;
pub use string::NewStringType;
pub use string::WriteOptions;
pub use support::SharedPtr;
pub use support::SharedRef;
pub use support::UniquePtr;

View file

@ -156,6 +156,15 @@ fn test_string() {
assert_eq!(15, local.length());
assert_eq!(17, local.utf8_length(scope));
assert_eq!(reference, local.to_rust_string_lossy(scope));
let mut vec = Vec::new();
vec.resize(17, 0);
let options = v8::WriteOptions::NO_NULL_TERMINATION;
let mut nchars = 0;
assert_eq!(
17,
local.write_utf8(scope, &mut vec, Some(&mut nchars), options)
);
assert_eq!(15, nchars);
}
{
let scope = &mut v8::HandleScope::new(isolate);