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:
parent
ada75e81d1
commit
774e34adf1
1 changed files with 9 additions and 0 deletions
|
@ -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) }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue