0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-22 15:07:00 -05:00

Deref String to Value

This commit is contained in:
Ryan Dahl 2019-12-09 07:19:22 +08:00 committed by Ry Dahl
parent ada75e81d1
commit 774e34adf1

View file

@ -1,6 +1,7 @@
use std::convert::TryInto;
use std::default::Default;
use std::mem::forget;
use std::ops::Deref;
use std::slice;
use crate::isolate::CxxIsolate;
@ -10,6 +11,7 @@ use crate::support::int;
use crate::support::Opaque;
use crate::HandleScope;
use crate::Local;
use crate::Value;
extern "C" {
fn v8__String__NewFromUtf8(
@ -142,3 +144,10 @@ impl String {
unsafe { std::string::String::from_raw_parts(data, length, capacity) }
}
}
impl Deref for String {
type Target = Value;
fn deref(&self) -> &Self::Target {
unsafe { &*(self as *const _ as *const Value) }
}
}