#once #called #call #thread-safe #sync #api #sucessfully

no-std call-once

A type that can only be called sucessfully once

1 unstable release

0.1.0 Aug 28, 2023

#2037 in Rust patterns

Download history 739/week @ 2024-02-14 559/week @ 2024-02-21 726/week @ 2024-02-28 489/week @ 2024-03-06 552/week @ 2024-03-13 685/week @ 2024-03-20 412/week @ 2024-03-27 1262/week @ 2024-04-03 914/week @ 2024-04-10 865/week @ 2024-04-17 491/week @ 2024-04-24 602/week @ 2024-05-01 637/week @ 2024-05-08 626/week @ 2024-05-15 617/week @ 2024-05-22 566/week @ 2024-05-29

2,575 downloads per month
Used in take-static

MIT/Apache

7KB

call-once

Crates.io docs.rs CI

This crate provides CallOnce, a simple, thread-safe type that can only be called successfully once:

use call_once::CallOnce;

static CALL_ONCE: CallOnce = CallOnce::new();

assert!(CALL_ONCE.call_once().is_ok());
assert!(CALL_ONCE.call_once().is_err());

For API documentation, see the docs.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps