mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Replace Root::deref by a custom get_unsound_ref_forever method.
This will hopefully make it clearer that this is not the correct function to call.
This commit is contained in:
parent
40c59724b2
commit
d8c2c88bbd
8 changed files with 70 additions and 61 deletions
|
@ -614,6 +614,17 @@ impl<T: Reflectable> Root<T> {
|
|||
chain: ContravariantLifetime,
|
||||
}
|
||||
}
|
||||
|
||||
/// Obtain an unsafe reference to the wrapped JS owned-value that can
|
||||
/// outlive the lifetime of this root.
|
||||
///
|
||||
/// DO NOT CALL.
|
||||
pub fn get_unsound_ref_forever<'b>(&self) -> JSRef<'b, T> {
|
||||
JSRef {
|
||||
ptr: self.jsref.ptr,
|
||||
chain: ContravariantLifetime,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
|
@ -623,13 +634,6 @@ impl<T: Reflectable> Drop for Root<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'b, T: Reflectable> Deref for Root<T> {
|
||||
type Target = JSRef<'b, T>;
|
||||
fn deref<'c>(&'c self) -> &'c JSRef<'b, T> {
|
||||
&self.jsref
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Reflectable> Deref for JSRef<'a, T> {
|
||||
type Target = T;
|
||||
fn deref<'b>(&'b self) -> &'b T {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue