mirror of
https://github.com/servo/servo.git
synced 2025-07-19 05:13:55 +01:00
Auto merge of #11317 - nox:castable, r=mbrubeck
Fix the doc on inheritance and casting <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11317) <!-- Reviewable:end -->
This commit is contained in:
commit
f1efeb00af
1 changed files with 5 additions and 5 deletions
|
@ -157,18 +157,18 @@
|
|||
//! Inheritance and casting
|
||||
//! =======================
|
||||
//!
|
||||
//! For all DOM interfaces `Foo` in an inheritance chain, a
|
||||
//! `dom::bindings::inheritance::FooCast` provides methods to cast
|
||||
//! to other types in the inheritance chain. For example:
|
||||
//! All DOM interfaces part of an inheritance chain (i.e. interfaces
|
||||
//! that derive others or are derived from) implement the trait `Castable`
|
||||
//! which provides both downcast and upcasts.
|
||||
//!
|
||||
//! ```ignore
|
||||
//! # use script::dom::bindings::inheritance::{NodeCast, HTMLElementCast};
|
||||
//! # use script::dom::bindings::inheritance::Castable;
|
||||
//! # use script::dom::element::Element;
|
||||
//! # use script::dom::node::Node;
|
||||
//! # use script::dom::htmlelement::HTMLElement;
|
||||
//! fn f(element: &Element) {
|
||||
//! let base = element.upcast::<Node>();
|
||||
//! let derived = element.downcast::<HTMLElement>();
|
||||
//! let derived = element.downcast::<HTMLElement>().unwrap();
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue