diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2018-06-29 10:34:09 -0700 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2018-07-03 09:39:29 -0700 |
commit | ad198993b127ef87f129add8336f8bb7dfd30e4d (patch) | |
tree | db1756c2241abbd068d81e4b07a4d481a55b5c73 /components/script/task_source/networking.rs | |
parent | e2fca1b228ff20d54b67e0d1fa502b694b5c290e (diff) | |
download | servo-ad198993b127ef87f129add8336f8bb7dfd30e4d.tar.gz servo-ad198993b127ef87f129add8336f8bb7dfd30e4d.zip |
Assert that DOM structs have the correct first field
DOM structs embed their parent type as their first field. This
introduces a `.parent()` method to the DOM struct that returns its first
field, and codegens a type assert that ensures that `.parent()` returns
the parent struct.
This generates:
On `#[dom_struct]`:
```rust
impl HasParent for Type {
type Parent = ParentType;
fn as_parent(&self) -> ParentType {
&self.first_field
}
}
```
In the codegen files:
```rust
impl Type {
fn __assert_parent_type(&self) {
let _: &ParentType = self.as_parent();
}
}
````
Diffstat (limited to 'components/script/task_source/networking.rs')
0 files changed, 0 insertions, 0 deletions