use std::collections::HashSet; use std::cell::RefCell; use super::Trait; use super::GlobalNamespace; #[derive(Clone, Copy)] pub struct Type<'a> { pub(super) id: usize, pub(super) namespace: &'a GlobalNamespace, } impl<'a> Type<'a> { pub fn add_trait(&self, to_add: &'a Trait) { let internal_self = &self.namespace.types.borrow()[self.id]; internal_self.traits.borrow_mut().insert(to_add.id); self.namespace.traits.borrow_mut()[to_add.id] .types .borrow_mut() .insert(self.id); } pub fn has_trait(&self, to_check: &'a Trait) -> bool { self.namespace.types.borrow()[self.id] .traits .borrow() .contains(&to_check.id) } } pub(super) struct InternalType { pub(super) traits: RefCell>, pub(super) name: String, }