Created
January 25, 2017 01:34
-
-
Save federicomenaquintero/511ee376e3010ecfcfff6077ecdfca0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct Node<'a> { | |
node_type: NodeType, | |
parent: RefCell<Option<Weak<Node<'a>>>>, // cell for interior mutability; optional; weak ref to parent | |
children: Vec<Rc<Node<'a>>>, // strong references to children | |
state: *mut RsvgState, | |
node_impl: &'a NodeTrait | |
} | |
impl<'a> Node<'a> { | |
// ... | |
pub fn add_child (&mut self, child: &Rc<Node<'a>>) { | |
self.children.push (child.clone ()); | |
} | |
} | |
type RsvgRcNode<'a> = Rc<Node<'a>>; | |
#[no_mangle] | |
pub extern fn rsvg_node_add_child<'a> (raw_node: *mut RsvgRcNode<'a>, raw_child: *const RsvgRcNode<'a>) { | |
assert! (!raw_node.is_null ()); | |
let rc_node: &mut RsvgRcNode<'a> = unsafe { &mut *raw_node }; | |
let rc_child: &RsvgRcNode<'a> = unsafe { & *raw_child }; | |
rc_node.add_child (rc_child); | |
} | |
error: cannot borrow immutable borrowed content as mutable | |
--> node.rs:160:5 | |
| | |
160 | rc_node.add_child (rc_child); | |
| ^^^^^^^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment