Skip to content

Commit b7aec67

Browse files
committed
Remove setting MSRV deps in CI and use stdlib instead of once_cell where possible
1 parent b61e50e commit b7aec67

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,6 @@ jobs:
126126
toolchain: ${{ matrix.rust }}
127127
target: ${{ matrix.platform.rust-target }}
128128

129-
- if: ${{ matrix.msrv == 'MSRV' }}
130-
name: Set MSRV dependencies
131-
run: |
132-
cargo add tokio@=1.38.1
133-
cargo update -p once_cell --precise 1.20.3
134-
135129
- name: Build (no features)
136130
run: cargo build --no-default-features --verbose --target ${{ matrix.platform.rust-target }}
137131

src/generic.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ use crate::{
2727
use futures::channel::oneshot;
2828
#[cfg(feature = "unstable-streams")]
2929
use futures::{channel::mpsc, SinkExt};
30-
#[cfg(feature = "unstable-streams")]
31-
use once_cell::sync::OnceCell;
3230
use pin_project_lite::pin_project;
3331
use pyo3::prelude::*;
32+
use pyo3::sync::PyOnceLock;
3433
use pyo3::IntoPyObjectExt;
3534
#[cfg(feature = "unstable-streams")]
3635
use std::marker::PhantomData;
@@ -1660,10 +1659,10 @@ where
16601659
{
16611660
use std::ffi::CString;
16621661

1663-
static GLUE_MOD: OnceCell<Py<PyAny>> = OnceCell::new();
1662+
static GLUE_MOD: PyOnceLock<Py<PyAny>> = PyOnceLock::new();
16641663
let py = gen.py();
16651664
let glue = GLUE_MOD
1666-
.get_or_try_init(|| -> PyResult<Py<PyAny>> {
1665+
.get_or_try_init(py, || -> PyResult<Py<PyAny>> {
16671666
Ok(PyModule::from_code(
16681667
py,
16691668
&CString::new(STREAM_GLUE).unwrap(),

src/tokio.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@
1313
//! features = ["unstable-streams"]
1414
//! ```
1515
16+
use std::cell::OnceCell;
1617
use std::ops::Deref;
18+
use std::sync::OnceLock;
1719
use std::{future::Future, pin::Pin, sync::Mutex};
1820

1921
use ::tokio::{
2022
runtime::{Builder, Runtime},
2123
task,
2224
};
23-
use once_cell::{
24-
sync::{Lazy, OnceCell},
25-
unsync::OnceCell as UnsyncOnceCell,
26-
};
25+
use once_cell::sync::Lazy;
2726
use pyo3::prelude::*;
2827

2928
use crate::{
@@ -66,7 +65,7 @@ impl Deref for Pyo3Runtime {
6665
}
6766

6867
static TOKIO_BUILDER: Lazy<Mutex<Builder>> = Lazy::new(|| Mutex::new(multi_thread()));
69-
static TOKIO_RUNTIME: OnceCell<Pyo3Runtime> = OnceCell::new();
68+
static TOKIO_RUNTIME: OnceLock<Pyo3Runtime> = OnceLock::new();
7069

7170
impl generic::JoinError for task::JoinError {
7271
fn is_panic(&self) -> bool {
@@ -80,7 +79,7 @@ impl generic::JoinError for task::JoinError {
8079
struct TokioRuntime;
8180

8281
tokio::task_local! {
83-
static TASK_LOCALS: UnsyncOnceCell<TaskLocals>;
82+
static TASK_LOCALS: OnceCell<TaskLocals>;
8483
}
8584

8685
impl GenericRuntime for TokioRuntime {
@@ -102,7 +101,7 @@ impl ContextExt for TokioRuntime {
102101
where
103102
F: Future<Output = R> + Send + 'static,
104103
{
105-
let cell = UnsyncOnceCell::new();
104+
let cell = OnceCell::new();
106105
cell.set(locals).unwrap();
107106

108107
Box::pin(TASK_LOCALS.scope(cell, fut))
@@ -132,7 +131,7 @@ impl LocalContextExt for TokioRuntime {
132131
where
133132
F: Future<Output = R> + 'static,
134133
{
135-
let cell = UnsyncOnceCell::new();
134+
let cell = OnceCell::new();
136135
cell.set(locals).unwrap();
137136

138137
Box::pin(TASK_LOCALS.scope(cell, fut))

0 commit comments

Comments
 (0)