| Crates.io | local_static |
| lib.rs | local_static |
| version | 0.1.1 |
| created_at | 2025-01-21 01:56:30.21989+00 |
| updated_at | 2025-01-21 02:13:50.875053+00 |
| description | Local static variable |
| homepage | |
| repository | https://github.com/Merisy-Thing/rust_hal_with_c_sdk_framework/tree/main/local-static |
| max_upload_size | |
| id | 1524496 |
| size | 6,676 |
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.
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
}
}