-
|
I saw the class example here, but it's not quite what I was looking for. I am trying to return an object from a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
|
You can construct a #[derive(Trace, Finalize, JsData)]
#[boa_gc(unsafe_empty_trace)]
struct MyType {
field1: TypeWithoutTrace,
field2: TypeWithoutTrace,
}Of course, if you can implement After that, just construct an object with the data you require: let data = MyType { field1: TypeWithoutTrace::new(), field2: TypeWithoutTrace::new() };
let obj = JsObject::from_proto_and_data(prototype, data)You'll have to pick a prototype for the object though. Generally, To get the inner data, you can do |
Beta Was this translation helpful? Give feedback.
Ahhh, right. To construct an instance of
Personyou need to call eitherClass::from_data(if you already have the data you want to initialize) orClass::construct, if you want to construct from JS args. That will set the correct prototype, since you're setting it toObjectin the snippet you provided.