On Wed, Mar 5, 2014 at 11:33 AM, Josh Matthews <j...@joshmatthews.net>wrote:
> I know that some contributors have expressed confusion about the new JS<T> > types that are all over the DOM. I've started a guide to try and clear up > how to use them; please feel free to suggest further topics or make edits > yourself: https://github.com/mozilla/servo/wiki/JS-smart-pointers > let base: JS<Node> = NodeCast::from(element);if base.get().type_id() == ElementNodeTypeId(HTMLTitleElementTypeId) { let derived: JS<HTMLTitleElement> = HTMLTitleElementCast::to(element);} Can this not be simplified to something like let derived = HTMLTitleElement::checkedCast(element); returning an Option<JS<HTMLTitleElement>>? Less verbose and less error-prone that the instanceof/downcast pattern. Rob -- Jtehsauts tshaei dS,o n" Wohfy Mdaon yhoaus eanuttehrotraiitny eovni le atrhtohu gthot sf oirng iyvoeu rs ihnesa.r"t sS?o Whhei csha iids teoa stiheer :p atroa lsyazye,d 'mYaonu,r "sGients uapr,e tfaokreg iyvoeunr, 'm aotr atnod sgaoy ,h o'mGee.t" uTph eann dt hwea lmka'n? gBoutt uIp waanndt wyeonut thoo mken.o w _______________________________________________ dev-servo mailing list dev-servo@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-servo