singly

Crates.iosingly
lib.rssingly
version0.1.1
sourcesrc
created_at2024-03-12 04:37:35.862551
updated_at2024-03-12 04:59:26.892649
descriptionLightweight "not" thread safe singleton but it depend on the usage though
homepage
repositoryhttps://github.com/UnknownRori/singly-rs
max_upload_size
id1170104
size14,081
UnknownRori (UnknownRori)

documentation

README

Singly

Simple, Lighweight and "not" thread safe Singleton instance but it depend on the usage, consult the docs for more information regarding thread safety, feel free to make thread safe wrapper

Features

  • Set value to the instance with type.
  • Get reference value to the instance with type.
  • Get mutable reference value to the instance with type.
  • Work at no_std environment

Examples

fn main() {
   // Create the Singleton instance
   let mut instance = singly::Singleton::new();

   /// Set the i32 type to 12
   instance.set(12i32);

   /// Get mutable reference i32 type and set it to 14
   let a = instance.get_mut::<i32>();
   *a = 14;

   assert_eq!(instance.get::<i32>(), &14);

}

Installation

cargo add singly

License

This project is licensed under MIT

Commit count: 0

cargo fmt