Skip to content

Commit df72e48

Browse files
fix errors
1 parent c549c27 commit df72e48

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

src/change_stream/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use crate::{
4545
/// A `ChangeStream` can be iterated like any other [`Stream`]:
4646
///
4747
/// ```
48-
/// # #[cfg(all(not(feature = "sync"), not(feature = "tokio-sync"))]
48+
/// # #[cfg(all(not(feature = "sync"), not(feature = "tokio-sync")))]
4949
/// # use futures::stream::StreamExt;
5050
/// # use mongodb::{Client, error::Result, bson::doc,
5151
/// # change_stream::event::ChangeStreamEvent};

src/client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const DEFAULT_SERVER_SELECTION_TIMEOUT: Duration = Duration::from_secs(30);
5959
/// # #[cfg(feature = "tokio-runtime")]
6060
/// # use tokio::task;
6161
/// #
62-
/// # #[cfg(all(not(feature = "sync"), not(feature = "tokio-sync"))]
62+
/// # #[cfg(all(not(feature = "sync"), not(feature = "tokio-sync")))]
6363
/// # async fn start_workers() -> Result<()> {
6464
/// let client = Client::with_uri_str("mongodb://example.com").await?;
6565
///

src/db/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use crate::{
4646
///
4747
/// ```rust
4848
///
49-
/// # #[cfg(all(not(feature = "sync"), not(feature = "tokio-sync"))]
49+
/// # #[cfg(all(not(feature = "sync"), not(feature = "tokio-sync")))]
5050
/// # use mongodb::{bson::Document, Client, error::Result};
5151
/// # #[cfg(feature = "async-std-runtime")]
5252
/// # use async_std::task;

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ pub(crate) use crate::{
357357

358358
pub use {coll::Namespace, index::IndexModel, client::session::ClusterTime, sdam::public::*};
359359

360-
// isabeltodo
361360
#[cfg(all(
362361
feature = "tokio-runtime",
363362
feature = "async-std-runtime",

src/runtime/mod.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@ where
3636
F: Future<Output = O> + Send + 'static,
3737
O: Send + 'static,
3838
{
39-
#[cfg(feature = "tokio-runtime")]
39+
#[cfg(all(feature = "tokio-runtime", not(feature = "tokio-sync")))]
4040
{
4141
let handle = tokio::runtime::Handle::current();
4242
AsyncJoinHandle::Tokio(handle.spawn(fut))
4343
}
4444

45+
#[cfg(feature = "tokio-sync")]
46+
{
47+
let handle = crate::sync::TOKIO_RUNTIME.handle();
48+
AsyncJoinHandle::Tokio(handle.spawn(fut))
49+
}
50+
4551
#[cfg(feature = "async-std-runtime")]
4652
{
4753
AsyncJoinHandle::AsyncStd(async_std::task::spawn(fut))
@@ -59,19 +65,19 @@ where
5965
spawn(fut);
6066
}
6167

62-
#[cfg(test)]
68+
#[cfg(any(test, feature = "sync", feature = "tokio-sync"))]
6369
pub(crate) fn block_on<F, T>(fut: F) -> T
6470
where
6571
F: Future<Output = T>,
6672
{
67-
#[cfg(feature = "tokio-sync")]
73+
#[cfg(all(feature = "tokio-runtime", not(feature = "tokio-sync")))]
6874
{
69-
crate::sync::TOKIO_RUNTIME.block_on(fut)
75+
tokio::task::block_in_place(|| futures::executor::block_on(fut))
7076
}
7177

72-
#[cfg(all(feature = "tokio-runtime", not(feature = "tokio-sync")))]
78+
#[cfg(feature = "tokio-sync")]
7379
{
74-
tokio::task::block_in_place(|| futures::executor::block_on(fut))
80+
crate::sync::TOKIO_RUNTIME.block_on(fut)
7581
}
7682

7783
#[cfg(feature = "async-std-runtime")]

src/sync/test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,11 @@ fn collection_generic_bounds() {
276276
#[derive(Deserialize)]
277277
struct Foo;
278278

279+
println!("1");
279280
let options = CLIENT_OPTIONS.clone();
281+
println!("2");
280282
let client = Client::with_options(options).expect("client creation should succeed");
283+
println!("3");
281284

282285
// ensure this code successfully compiles
283286
let coll: Collection<Foo> = client

0 commit comments

Comments
 (0)