mirror of
https://github.com/servo/servo
synced 2026-05-01 20:07:22 +02: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:
@@ -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() }
|
||||
|
||||
Reference in New Issue
Block a user