mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Add a to_js method to the casting trait code in CodegenRust.py
Replace the manual checks and calls to transmute_copy in /layout/wrapper.rs with calls to to_js Fixes #3616
This commit is contained in:
parent
3eb6b17137
commit
6d91e92c90
2 changed files with 69 additions and 61 deletions
|
@ -5480,6 +5480,17 @@ class GlobalGenRoots():
|
|||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[allow(unrooted_must_root)]
|
||||
fn to_js<T: ${toBound}+Reflectable>(base: &JS<T>) -> Option<JS<Self>> {
|
||||
unsafe {
|
||||
match (*base.unsafe_get()).${checkFn}() {
|
||||
true => Some(base.transmute_copy()),
|
||||
false => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn from_ref<'a, T: ${fromBound}+Reflectable>(derived: JSRef<'a, T>) -> JSRef<'a, Self> {
|
||||
unsafe { derived.transmute() }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue