mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Fix the doc on inheritance and casting
This commit is contained in:
parent
1a34137ac4
commit
7e06fb0c8a
1 changed files with 5 additions and 5 deletions
|
@ -157,18 +157,18 @@
|
||||||
//! Inheritance and casting
|
//! Inheritance and casting
|
||||||
//! =======================
|
//! =======================
|
||||||
//!
|
//!
|
||||||
//! For all DOM interfaces `Foo` in an inheritance chain, a
|
//! All DOM interfaces part of an inheritance chain (i.e. interfaces
|
||||||
//! `dom::bindings::inheritance::FooCast` provides methods to cast
|
//! that derive others or are derived from) implement the trait `Castable`
|
||||||
//! to other types in the inheritance chain. For example:
|
//! which provides both downcast and upcasts.
|
||||||
//!
|
//!
|
||||||
//! ```ignore
|
//! ```ignore
|
||||||
//! # use script::dom::bindings::inheritance::{NodeCast, HTMLElementCast};
|
//! # use script::dom::bindings::inheritance::Castable;
|
||||||
//! # use script::dom::element::Element;
|
//! # use script::dom::element::Element;
|
||||||
//! # use script::dom::node::Node;
|
//! # use script::dom::node::Node;
|
||||||
//! # use script::dom::htmlelement::HTMLElement;
|
//! # use script::dom::htmlelement::HTMLElement;
|
||||||
//! fn f(element: &Element) {
|
//! fn f(element: &Element) {
|
||||||
//! let base = element.upcast::<Node>();
|
//! 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