mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-03-09 21:47:00 -04: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::convert::TryInto;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::mem::forget;
|
use std::mem::forget;
|
||||||
|
use std::ops::Deref;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
use crate::isolate::CxxIsolate;
|
use crate::isolate::CxxIsolate;
|
||||||
|
@ -10,6 +11,7 @@ use crate::support::int;
|
||||||
use crate::support::Opaque;
|
use crate::support::Opaque;
|
||||||
use crate::HandleScope;
|
use crate::HandleScope;
|
||||||
use crate::Local;
|
use crate::Local;
|
||||||
|
use crate::Value;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn v8__String__NewFromUtf8(
|
fn v8__String__NewFromUtf8(
|
||||||
|
@ -142,3 +144,10 @@ impl String {
|
||||||
unsafe { std::string::String::from_raw_parts(data, length, capacity) }
|
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…
Add table
Reference in a new issue