#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

#2015 in Rust patterns

Download history 845/week @ 2024-07-21 813/week @ 2024-07-28 596/week @ 2024-08-04 584/week @ 2024-08-11 676/week @ 2024-08-18 1071/week @ 2024-08-25 664/week @ 2024-09-01 491/week @ 2024-09-08 715/week @ 2024-09-15 397/week @ 2024-09-22 879/week @ 2024-09-29 700/week @ 2024-10-06 391/week @ 2024-10-13 675/week @ 2024-10-20 486/week @ 2024-10-27 535/week @ 2024-11-03

2,156 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