mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Fix LayoutDom::unsafe_get
The raw pointer can be used to extend the lifetime of the inner T to beyond 'dom.
This commit is contained in:
parent
4279fe5933
commit
ea9e62bdca
1 changed files with 4 additions and 5 deletions
|
@ -748,12 +748,11 @@ impl<'dom, T> LayoutDom<'dom, T>
|
|||
where
|
||||
T: 'dom + DomObject,
|
||||
{
|
||||
/// Returns an unsafe pointer to the interior of this JS object. This is
|
||||
/// the only method that be safely accessed from layout. (The fact that
|
||||
/// this is unsafe is what necessitates the layout wrappers.)
|
||||
pub unsafe fn unsafe_get(&self) -> *const T {
|
||||
/// Returns a reference to the interior of this JS object. The fact
|
||||
/// that this is unsafe is what necessitates the layout wrappers.
|
||||
pub unsafe fn unsafe_get(self) -> &'dom T {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
self.ptr.as_ptr()
|
||||
&*self.ptr.as_ptr()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue