diff options
author | Ms2ger <ms2ger@gmail.com> | 2014-12-20 13:42:38 +0100 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2014-12-20 13:42:38 +0100 |
commit | e1dae2f59b41d9816be367f765ff3afb9abf7f06 (patch) | |
tree | dc9467964067c18b1d1b6288be6457a1241efd1d /components/script/dom/bindings | |
parent | 58e7b8c154cae663ee82b6c042044de68c43a007 (diff) | |
download | servo-e1dae2f59b41d9816be367f765ff3afb9abf7f06.tar.gz servo-e1dae2f59b41d9816be367f765ff3afb9abf7f06.zip |
Use the try macro in unwrap_jsmanaged.
Diffstat (limited to 'components/script/dom/bindings')
-rw-r--r-- | components/script/dom/bindings/utils.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index f598068fa53..4f12d1dbc7d 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -127,7 +127,7 @@ pub fn unwrap_jsmanaged<T: Reflectable>(mut obj: *mut JSObject, proto_id: PrototypeList::ID, proto_depth: uint) -> Result<JS<T>, ()> { unsafe { - let dom_class = get_dom_class(obj).or_else(|_| { + let dom_class = try!(get_dom_class(obj).or_else(|_| { if IsWrapper(obj) == 1 { debug!("found wrapper"); obj = UnwrapObject(obj, /* stopAtOuter = */ 0, ptr::null_mut()); @@ -143,17 +143,15 @@ pub fn unwrap_jsmanaged<T: Reflectable>(mut obj: *mut JSObject, debug!("not a dom wrapper"); Err(()) } - }); - - dom_class.and_then(|dom_class| { - if dom_class.interface_chain[proto_depth] == proto_id { - debug!("good prototype"); - Ok(JS::from_raw(unwrap(obj))) - } else { - debug!("bad prototype"); - Err(()) - } - }) + })); + + if dom_class.interface_chain[proto_depth] == proto_id { + debug!("good prototype"); + Ok(JS::from_raw(unwrap(obj))) + } else { + debug!("bad prototype"); + Err(()) + } } } |