diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-18 10:41:16 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-18 10:42:05 +0200 |
commit | 851d40b204da546d5200e421439118b4e12c8d74 (patch) | |
tree | 83b6e21999d26ad2460c11337def5f7020f3a00a /components/script/dom/bindings/refcounted.rs | |
parent | ad41ce7a6f679f4fda1382f010a0b7b145421708 (diff) | |
download | servo-851d40b204da546d5200e421439118b4e12c8d74.tar.gz servo-851d40b204da546d5200e421439118b4e12c8d74.zip |
Use task! to reject promises
Diffstat (limited to 'components/script/dom/bindings/refcounted.rs')
-rw-r--r-- | components/script/dom/bindings/refcounted.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs index 4da753cb833..c11232ee70a 100644 --- a/components/script/dom/bindings/refcounted.rs +++ b/components/script/dom/bindings/refcounted.rs @@ -123,18 +123,14 @@ impl TrustedPromise { /// A task which will reject the promise. #[allow(unrooted_must_root)] pub fn reject_task(self, error: Error) -> impl Send + Task { - struct RejectPromise(TrustedPromise, Error); - impl Task for RejectPromise { - fn run(self: Box<Self>) { - debug!("Rejecting promise."); - let this = *self; - let promise = this.0.root(); - let cx = promise.global().get_cx(); - let _ac = JSAutoCompartment::new(cx, promise.reflector().get_jsobject().get()); - promise.reject_error(cx, this.1); - } - } - RejectPromise(self, error) + let this = self; + task!(reject_promise: move || { + debug!("Rejecting promise."); + let this = this.root(); + let cx = this.global().get_cx(); + let _ac = JSAutoCompartment::new(cx, this.reflector().get_jsobject().get()); + this.reject_error(cx, error); + }) } /// A task which will resolve the promise. |