2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-08-31 13:02:01 +00:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
#![allow(non_snake_case)]
|
|
|
|
|
2014-12-22 17:04:23 +00:00
|
|
|
use std::ops::Deref;
|
|
|
|
|
2014-12-07 15:22:06 +00:00
|
|
|
struct Root {
|
|
|
|
jsref: JSRef
|
|
|
|
}
|
|
|
|
|
2015-01-01 19:53:20 +00:00
|
|
|
impl Deref for Root {
|
|
|
|
type Target = JSRef;
|
|
|
|
|
2014-12-07 15:22:06 +00:00
|
|
|
fn deref<'a>(&'a self) -> &'a JSRef {
|
|
|
|
&self.jsref
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-30 13:38:27 +00:00
|
|
|
#[derive(Copy, Clone)]
|
2014-12-07 15:22:06 +00:00
|
|
|
struct JSRef {
|
|
|
|
node: *const Node
|
|
|
|
}
|
|
|
|
|
2015-01-01 19:53:20 +00:00
|
|
|
impl Deref for JSRef {
|
|
|
|
type Target = Node;
|
|
|
|
|
2014-12-07 15:22:06 +00:00
|
|
|
fn deref<'a>(&'a self) -> &'a Node {
|
|
|
|
self.get()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait INode {
|
|
|
|
fn RemoveChild(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
impl INode for JSRef {
|
|
|
|
fn RemoveChild(&self) {
|
|
|
|
self.get().RemoveChild(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl JSRef {
|
|
|
|
fn AddChild(&self) {
|
|
|
|
self.get().AddChild(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get<'a>(&'a self) -> &'a Node {
|
|
|
|
unsafe {
|
|
|
|
&*self.node
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Node;
|
|
|
|
|
|
|
|
impl Node {
|
2015-03-26 00:06:52 +00:00
|
|
|
fn RemoveChild(&self, _a: usize) {
|
2014-12-07 15:22:06 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn AddChild(&self, _a: usize) {
|
2014-12-07 15:22:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let n = Node;
|
|
|
|
let jsref = JSRef { node: &n };
|
|
|
|
let root = Root { jsref: jsref };
|
|
|
|
|
|
|
|
root.AddChild();
|
|
|
|
jsref.AddChild();
|
|
|
|
|
|
|
|
root.RemoveChild();
|
|
|
|
jsref.RemoveChild();
|
|
|
|
}
|