Add mem and obj modules, move to nightly

* mem and obj modules are roughly divided between doing memory-specific
  things and object-specific things
* Box::new_uninit() is a nightly feature and it's quite useful, so I'm
  enabling that for now
* Check out src/obj/attrs.rs for possible undefined behavior in the
  Attrs::new() function. I'm sure it'll be just fine.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-05-14 17:10:53 -04:00
parent e233ff1cfc
commit ccb12306d4
15 changed files with 615 additions and 0 deletions

26
src/obj/ctx.rs Normal file
View File

@@ -0,0 +1,26 @@
use crate::mem::{gc::Gc, BasicGc};
pub type DefaultGc = BasicGc;
pub struct ObjCtx<G=DefaultGc>
where
G: Gc,
{
gc: G,
}
impl<G> ObjCtx<G>
where
G: Gc,
{
pub fn new(gc: G) -> Self {
ObjCtx { gc }
}
pub fn gc(&self) -> &G {
&self.gc
}
pub fn gc_mut(&mut self) -> &mut G {
&mut self.gc
}
}