eko_gc/
lib.rs

1#![feature(dropck_eyepatch)]
2
3/// This module lets you create garbage-collected arenas
4///
5/// ```compile_fail
6/// use eko_gc::{Gc, GcArena, Trace};
7///
8/// pub struct NamedObject {
9///   pub name: String,
10/// }
11///
12/// impl Trace for NamedObject {
13///   fn trace(&self) {}
14///   fn root(&self) {}
15///   fn unroot(&self) {}
16/// }
17///
18/// fn main() {
19///   let message: Gc<NamedObject>;
20///   {
21///     let arena: GcArena = GcArena::new();
22///     message = arena.alloc(NamedObject { name: String::from("Hello, World!") }).unwrap();
23///   }
24///   println!("{}", message.name);
25/// }
26/// ```
27///
28/// ```compile_fail
29/// use eko_gc::{Gc, GcArena, Trace};
30///
31/// pub struct RefNamedObject<'a> {
32///   pub name: &'a str,
33/// }
34///
35/// impl<'a> Trace for RefNamedObject<'a> {
36///   fn trace(&self) {}
37///   fn root(&self) {}
38///   fn unroot(&self) {}
39/// }
40///
41/// fn main() {
42///   let arena: GcArena = GcArena::new();
43///   let message: Gc<RefNamedObject>;
44///   {
45///     let hello_world: String = String::from("Hello, World!");
46///     message = arena.alloc(RefNamedObject { name: &hello_world }).unwrap();
47///   }
48/// }
49/// ```
50pub use self::gc::Gc;
51pub use self::gc_arena::GcArena;
52pub use self::gc_ref_cell::{GcRef, GcRefCell, GcRefMut};
53pub use self::trace::Trace;
54
55mod gc;
56mod gc_arena;
57mod gc_box;
58mod gc_ref_cell;
59mod trace;