1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use crate::mem::manager::Manager;

use super::{
    any::Any,
    any_cast::AnyCast,
    js_array::new_array,
    js_object::new_object,
    js_string::{new_string, JsStringRef},
};

pub trait New: Manager {
    fn new_js_array(
        self,
        i: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = Any<Self::Dealloc>>>,
    ) -> Any<Self::Dealloc> {
        new_array(self, i).to_ref().move_to_any()
    }
    fn new_js_string(
        self,
        s: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = u16>>,
    ) -> Any<Self::Dealloc> {
        new_string(self, s).to_ref().move_to_any()
    }
    fn new_js_object(
        self,
        i: impl IntoIterator<
            IntoIter = impl ExactSizeIterator<Item = (JsStringRef<Self::Dealloc>, Any<Self::Dealloc>)>,
        >,
    ) -> Any<Self::Dealloc> {
        new_object(self, i).to_ref().move_to_any()
    }
}

impl<M: Manager> New for M {}