diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-02-11 21:02:59 +0100 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-02-12 20:59:22 +0100 |
commit | 8ab7d37ef26559073ea1b981e70758eb4cd86f68 (patch) | |
tree | 1ab91cbbb4875fb640a384e0686e19d1fc82e130 /components/script/dom/bindings/js.rs | |
parent | b655b54f8022d963460e510511ad774a1a1d9ccd (diff) | |
download | servo-8ab7d37ef26559073ea1b981e70758eb4cd86f68.tar.gz servo-8ab7d37ef26559073ea1b981e70758eb4cd86f68.zip |
Add Unrooted::from_js.
There should not be a JS here; that is #2661. Until that's fixed, though,
it's better to encapsulate it.
Diffstat (limited to 'components/script/dom/bindings/js.rs')
-rw-r--r-- | components/script/dom/bindings/js.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index 970281c2977..ea4a8af2f56 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -83,6 +83,14 @@ impl<T: Reflectable> Unrooted<T> { } } + /// Create a new unrooted value from a `JS<T>`. + #[allow(unrooted_must_root)] + pub fn from_js(ptr: JS<T>) -> Unrooted<T> { + Unrooted { + ptr: ptr.ptr + } + } + /// Get the `Reflector` for this pointer. pub fn reflector<'a>(&'a self) -> &'a Reflector { unsafe { |