mini_v8/
string.rs

1use crate::*;
2use std::fmt;
3use std::string::String as StdString;
4
5#[derive(Clone)]
6pub struct String {
7    pub(crate) mv8: MiniV8,
8    pub(crate) handle: v8::Global<v8::String>,
9}
10
11impl String {
12    /// Returns a Rust string converted from the V8 string.
13    pub fn to_string(&self) -> StdString {
14        self.mv8.scope(|scope| {
15            v8::Local::new(scope, self.handle.clone()).to_rust_string_lossy(scope)
16        })
17    }
18}
19
20impl fmt::Debug for String {
21    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22        write!(f, "{:?}", self.to_string())
23    }
24}