Skip to content

Commit

Permalink
Merge branch 'matklad:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dynos01 committed Jun 5, 2023
2 parents 919e4ae + 93a98c7 commit e2c8ef1
Show file tree
Hide file tree
Showing 18 changed files with 1,176 additions and 1,146 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,16 @@

## Unreleased

-
-

## 1.18.0

- `MSRV` is updated to 1.60.0 to take advantage of `dep:` syntax for cargo features,
removing "implementation details" from publicly visible surface.

## 1.17.2

- Avoid unnecessary synchronization in `Lazy::{force,deref}_mut()`, [#231](https://github.com/matklad/once_cell/pull/231).

## 1.17.1

Expand Down
110 changes: 55 additions & 55 deletions Cargo.lock.msrv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 7 additions & 15 deletions Cargo.toml
@@ -1,10 +1,10 @@
[package]
name = "once_cell"
version = "1.17.1"
version = "1.18.0"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.56"
rust-version = "1.60"

description = "Single assignment cells and lazy values."
readme = "README.md"
Expand All @@ -20,17 +20,13 @@ exclude = ["*.png", "*.svg", "/Cargo.lock.msrv", "rustfmt.toml"]
members = ["xtask"]

[dependencies]
# These optional dependencies are considered private impl details,
# only features from `[features]` table are a part of semver-guarded API.
parking_lot_core = { version = "0.9.3", optional = true, default_features = false }
atomic_polyfill = { package = "atomic-polyfill", version = "1", optional = true }
critical_section = { package = "critical-section", version = "1", optional = true }
atomic-polyfill = { version = "1", optional = true }
critical-section = { version = "1", optional = true }

[dev-dependencies]
lazy_static = "1.0.0"
crossbeam-utils = "0.8.7"
regex = "1.2.0"
critical_section = { package = "critical-section", version = "1.1.1", features = ["std"] }
critical-section = { version = "1.1.1", features = ["std"] }

[features]
default = ["std"]
Expand All @@ -47,12 +43,12 @@ race = []
# Uses parking_lot to implement once_cell::sync::OnceCell.
# This makes no speed difference, but makes each OnceCell<T>
# up to 16 bytes smaller, depending on the size of the T.
parking_lot = ["parking_lot_core"]
parking_lot = ["dep:parking_lot_core"]

# Uses `critical-section` to implement `sync` and `race` modules. in
# `#![no_std]` mode. Please read `critical-section` docs carefully
# before enabling this feature.
critical-section = ["critical_section", "atomic_polyfill" ]
critical-section = ["dep:critical-section", "dep:atomic-polyfill" ]

# Enables semver-exempt APIs of this crate.
# At the moment, this feature is unused.
Expand All @@ -69,10 +65,6 @@ required-features = ["std"]
name = "bench_acquire"
required-features = ["std"]

[[example]]
name = "bench_vs_lazy_static"
required-features = ["std"]

[[example]]
name = "lazy_static"
required-features = ["std"]
Expand Down
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -54,5 +54,4 @@ More patterns and use-cases are in the [docs](https://docs.rs/once_cell/)!
* [async_once_cell](https://crates.io/crates/async_once_cell)
* [generic_once_cell](https://crates.io/crates/generic_once_cell) (bring your own mutex)

The API of `once_cell` is being proposed for inclusion in
[`std`](https://github.com/rust-lang/rfcs/pull/2788).
Parts of `once_cell` API are included into `std` [as of Rust 1.70.0](https://github.com/rust-lang/rust/pull/105587).
51 changes: 0 additions & 51 deletions examples/bench_vs_lazy_static.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/imp_cs.rs
Expand Up @@ -63,7 +63,7 @@ impl<T> OnceCell<T> {
pub(crate) unsafe fn get_unchecked(&self) -> &T {
debug_assert!(self.is_initialized());
// SAFETY: The caller ensures that the value is initialized and access synchronized.
crate::unwrap_unchecked(self.value.borrow(CriticalSection::new()).get())
self.value.borrow(CriticalSection::new()).get().unwrap_unchecked()
}

/// Gets the mutable reference to the underlying value, without checking if the cell
Expand Down
4 changes: 2 additions & 2 deletions src/imp_pl.rs
Expand Up @@ -58,7 +58,7 @@ impl<T> OnceCell<T> {
// but that is more complicated
// - finally, if it returns Ok, we store the value and store the flag with
// `Release`, which synchronizes with `Acquire`s.
let f = unsafe { crate::unwrap_unchecked(f.take()) };
let f = unsafe { f.take().unwrap_unchecked() };
match f() {
Ok(value) => unsafe {
// Safe b/c we have a unique access and no panic may happen
Expand Down Expand Up @@ -101,7 +101,7 @@ impl<T> OnceCell<T> {
pub(crate) unsafe fn get_unchecked(&self) -> &T {
debug_assert!(self.is_initialized());
let slot = &*self.value.get();
crate::unwrap_unchecked(slot.as_ref())
slot.as_ref().unwrap_unchecked()
}

/// Gets the mutable reference to the underlying value, without checking if the cell
Expand Down

0 comments on commit e2c8ef1

Please sign in to comment.