local_static

Crates.iolocal_static
lib.rslocal_static
version0.1.1
created_at2025-01-21 01:56:30.21989+00
updated_at2025-01-21 02:13:50.875053+00
descriptionLocal static variable
homepage
repositoryhttps://github.com/Merisy-Thing/rust_hal_with_c_sdk_framework/tree/main/local-static
max_upload_size
id1524496
size6,676
(Merisy-Thing)

documentation

README

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
	}
}
Commit count: 39

cargo fmt