1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use crate::{AtomId, AtomRoot, Readable, Writable};

pub type Atom<T> = fn(AtomBuilder) -> T;
pub struct AtomBuilder;

impl<V: 'static> Readable<V> for Atom<V> {
    fn read(&self, _root: AtomRoot) -> Option<V> {
        todo!()
    }
    fn init(&self) -> V {
        (*self)(AtomBuilder)
    }
    fn unique_id(&self) -> AtomId {
        AtomId {
            ptr: *self as *const (),
            type_id: std::any::TypeId::of::<V>(),
        }
    }
}

impl<V: 'static> Writable<V> for Atom<V> {
    fn write(&self, _root: AtomRoot, _value: V) {
        todo!()
    }
}

#[test]
fn atom_compiles() {
    static TEST_ATOM: Atom<&str> = |_| "hello";
    dbg!(TEST_ATOM.init());
}