Registry / async / async-once

async-once

JSON →
library0.2.6rscratesunverified

async once tool for lazy_static

# Cargo.toml [dependencies] async_once = "0.2.6"
INSTALL
IMPORT
SIG · ASYNC-ONCE
A
async-once
asyncrustv0.2.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AsyncOnce
use async_once::AsyncOnce;

Initialize a value asynchronously once using AsyncOnce

use async_once::AsyncOnce; use lazy_static::lazy_static; lazy_static! { static ref CONFIG: AsyncOnce<String> = AsyncOnce::new(); } #[tokio::main] async fn main() { let val = CONFIG.get_or_init(|| async { "hello".to_string() }).await; println!("{}", val); }
Debug
Known issues
gotchaRequires an async runtime (e.g., tokio) to call `get_or_init`.
fix
Add `tokio` or another async runtime as a dependency and use `#[tokio::main]` or similar.
affects: >=0.2.0
Upgrade
Version history
0.2.6latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
47 hits · last 30 days
node
42
OpenAI (training)
1
Resources
async-once — cargo add async-once · libregistry