matklad / once_cell

Rust library for single assignment cells and lazy statics without macros

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Documentation inconsistencies regarding parking_lot

parasyte opened this issue · comments

The parking_lot feature has been non-default since v1.0.0 (released 16 months ago). Docs claim it is enabled by default:

once_cell/src/lib.rs

Lines 236 to 239 in a648913

//! To implement a sync flavor of `OnceCell`, this crates uses either a custom re-implementation of
//! `std::sync::Once` or `parking_lot::Mutex`. This is controlled by the `parking_lot` feature, which
//! is enabled by default. Performance is the same for both cases, but the `parking_lot` based `OnceCell<T>`
//! is smaller by up to 16 bytes.

This section also claims the parking_lot feature saves up to 16 bytes. While a companion comment in Cargo.toml claims it saves up to 2 bytes. Which one of these claims is correct?

once_cell/Cargo.toml

Lines 22 to 25 in a648913

# Uses parking_lot to implement once_cell::sync::OnceCell.
# This makes not speed difference, but makes each OnceCell<T>
# for up to two bytes smaller, depending on the size of the T.
parking_lot = { version = "0.11", optional = true, default_features = false }