atomref.rs 592 B

12345678910111213141516171819202122232425
  1. use crate::{AtomId, AtomRoot, Readable};
  2. use std::cell::RefCell;
  3. pub struct AtomRefBuilder;
  4. pub struct AtomRef<T>(pub fn(AtomRefBuilder) -> T);
  5. impl<V> Readable<RefCell<V>> for &'static AtomRef<V> {
  6. fn read(&self, _root: AtomRoot) -> Option<RefCell<V>> {
  7. todo!()
  8. }
  9. fn init(&self) -> RefCell<V> {
  10. RefCell::new(self.0(AtomRefBuilder))
  11. }
  12. fn unique_id(&self) -> AtomId {
  13. *self as *const AtomRef<V> as *const ()
  14. }
  15. }
  16. #[test]
  17. fn atom_compiles() {
  18. static TEST_ATOM: AtomRef<Vec<String>> = AtomRef(|_| vec![]);
  19. dbg!((&TEST_ATOM).init());
  20. }