Closed DelSkayn closed 1 year ago
This causes some problems with who classes from rust are implemented.
Methods use the fact that class implement FromJs
for &T
where T: ClassDef
which is implemented using from_js_ref
.
However it is unsound to return a reference from FromJs
as it takes Value
by value and not reference.
I will have to look at some redesign with regards to class methods.
Class::<T>::from_js_ref()
has the following signature:The returned reference has the lifetime
'js
however the actual lifetime depends on the lifetime ofValue<'js>
. If this value is the only reference toT
,T
is immediately dropped inside the function and then the reference is returned. Example:A more correct signature would be: