This library is a natural extension of the std::cell::OnceCell (or its original crate once_cell) library. This library provides a single-linked list OnceList type that allows you to store multiple values in a single OnceList instance even without the need for the mutability.
If you need faster operations, consider enabling caching modes:
OnceListWithLen<T, A>: O(1)len()OnceListWithTail<T, A>: fast repeated tail inserts (e.g.push_back()/extend()); does not makeback()O(1)OnceListWithTailLen<T, A>: both (len O(1) + fast tail inserts)
Alternatives (Consider using these crates first!)
once_cell- The original crate that provides aOnceCelltype. If you only need to store a single value, this crate is quite enough.elsa- A crate that providesFrozencollection types that allows you to store multiple values without the need for the mutability. They provides something similar toVecorHashMap, so if your use case requires more than 3-ish values or you need more complex data structure than a single-linked list, then you should use this crate instead.
Features
By default, none of the features are enabled.
-
nightly: Enables the nightly-only features.- Uses the
allocator_apistd unstable feature. Note that even without this feature, this crate still supports the allocators thanks to theallocator_api2crate. - Supports the special methods for the unsized value types. See the doc of
OnceListfor more details.
- Uses the
-
sync: This library internally usesstd::cell::OnceCellwhich is not thread-safe. When you enable this feature, this library uses the thread-safestd::sync::OnceLockinstead.- Note: This does not make the caching modes thread-safe. The cache modes (
OnceListWithLen/OnceListWithTail/OnceListWithTailLen) are intentionally "single-thread oriented" and useCellinternally, so they do not implementSyncand cannot be shared across threads. If you need multi-thread access, use the defaultOnceList(no-cache mode), and ensureT/ allocator types satisfy the usualSend/Syncbounds.
- Note: This does not make the caching modes thread-safe. The cache modes (