gom 0.1.7

A simple Rust global object manager
Documentation
use gom::*;

const ROOT: &str = id!(ROOT);
const NOTE: &str = id!(@ROOT.note);

pub struct Note {
    text: String,
}

fn note(text: &str) -> String {
    if !Registry::<Note>::exists(NOTE) {
        let note = Note {
            text: Default::default(),
        };
        Registry::register(NOTE, note).unwrap();
    }
    Registry::<Note>::apply(NOTE, |t| {
        let ret = t.text.clone();
        t.text = text.to_string();
        ret
    })
    .unwrap()
}

fn main() {
    println!("{:?}", note("Hello, world!"));
    println!("{:?}", note("Goodbye, world!"));
    println!("{:?}", note("How are you?"));
}