Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::vec::Vec;
- use std::rc::{Weak,Rc};
- struct Component{
- parent: Weak<Compound>,
- active_site: Option< Box< ActiveSite > >,
- }
- impl Component{
- fn update(&self){
- if self.active_site.is_some() {
- self.active_site.as_ref().unwrap().update(self);
- }
- }
- }
- trait ActiveSite{
- fn update( &self, root: &Component);
- }
- struct Compound{
- components: Vec< Rc< Component > >,
- }
- impl Compound{
- /// Moves component and bind it's as part of the compound.
- fn addComponent(&mut self, c: Component){
- self.components.push(Rc::new(c));
- }
- fn removeComponent(&mut self, c: &mut Component ){
- self.components.remove(0);
- }
- }
- #[test]
- fn validate(){
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement