#object #manager #global

gom

A simple Rust global object manager

7 releases

new 0.1.6 Feb 8, 2025
0.1.5 Feb 7, 2025

#23 in #global

Download history 422/week @ 2025-02-01

422 downloads per month

MIT license

9KB
76 lines

Global Object Manager (GOM)

This is a simple global object manager that makes it easier for you to use global objects in Rust.

Note

You need to add crate constcat to support macro id!(...).

This is a flaw in Rust.

Example

use gom::*;

const VEC: &str = id!(Vec);
const ID: &str = id!(@VEC.Bar);

fn main() {
    Registry::register(ID, vec![1, 2, 3]);

    Registry::<Vec<i32>>::with(ID, |v| {
        v.push(4);
    });

    let v = Registry::<Vec<i32>>::remove(ID);
    println!("{:?}", v);
}

Dependencies

~25KB