diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-02-05 16:28:02 +0100 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-02-05 18:45:20 +0100 |
commit | d8c2c88bbda1ede44a4c202a91dea09e51d9190a (patch) | |
tree | 11d53d319f1ddc28204c70d70c8747c38112312b /components/script/dom/bindings/js.rs | |
parent | 40c59724b2638fee3b9932eba1aa9f6ebd77b0cd (diff) | |
download | servo-d8c2c88bbda1ede44a4c202a91dea09e51d9190a.tar.gz servo-d8c2c88bbda1ede44a4c202a91dea09e51d9190a.zip |
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.
Diffstat (limited to 'components/script/dom/bindings/js.rs')
-rw-r--r-- | components/script/dom/bindings/js.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index 02a6c430421..8b8f19e4d97 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -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 { |