local_static 0.1.1

Local static variable
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented1 out of 7 items with examples
  • Size
  • Source code size: 6.33 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 738.05 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Merisy-Thing

LocalStatic

LocalStatic is a interior mutable library that provides a way to store variables in static storage, allowing initialization at compile time and being unsafe-friendly for embedded programs.

Using LocalStatic in a multi-threaded or multi-core environment is extremely dangerous. Please use other thread-safe libraries such as lazy_static, once_cell, etc.

Usage

use local_static::LocalStatic;

{
	static TICK: LocalStatic<Tick> = LocalStatic::new();

	let tick = TICK.get_mut();
	if tick.elapsed_time().to_millis() >= 500 {
		*tick = Tick::now();

		//do something
	}
}