mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2025-09-25 16:01:30 +02:00
moved namespaces to their own module
This commit is contained in:
parent
91adcd40f5
commit
03412ce8cd
9 changed files with 326 additions and 304 deletions
37
src/namespace/type.rs
Normal file
37
src/namespace/type.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
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<HashSet<usize>>,
|
||||
pub(super) name: String,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue