Skip to content

Make futures default and tokio optional #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 3, 2021
Merged

Make futures default and tokio optional #12

merged 3 commits into from
Aug 3, 2021

Conversation

gsserge
Copy link
Member

@gsserge gsserge commented Jul 30, 2021

This PR implements the suggestion in #9 (comment)

Couldn't get the doctest to work with Tokio being optional, so just ignored it. Happy to take any suggestions how to actually make it work.

@geigerzaehler let me know what you think, thanks!

@gsserge gsserge requested review from seanpianka and rousan July 30, 2021 13:25
@seanpianka
Copy link
Member

It seems like you're able to conditionally include documentation using something like the following:

#![cfg_attr(feature = "alpha", doc = "
# Examples
```rust
fn alpha() {}
\``` # ignore leading slash
")]

Copy link
Contributor

@geigerzaehler geigerzaehler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Just one comment

src/lib.rs Outdated
@@ -2,7 +2,7 @@
//!
//! # Examples
//!
//! ```
//! ```ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of ignoring this example you can use the futures traits

diff --git a/src/lib.rs b/src/lib.rs
index 8593b93..345f539 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -7,3 +7,3 @@
 //! use async_pipe;
-//! use tokio::io::{AsyncWriteExt, AsyncReadExt};
+//! use futures::io::{AsyncWriteExt, AsyncReadExt};
 //!

Then the example compiles with the default flags.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, the futures traits do not play well with tokio which is still used in the doc test for spawning and executing. On macOS things are fine though, but on Linux the doc test never finishes (https://github.com/routerify/async-pipe-rs/actions/runs/1093123889).

I've tried to play with cfg attrs and conditional compilation, but unsuccessfully, and honestly it's not really worth the trouble. I'm just gonna revert back to tokio and because our CI uses cargo test --all-features it's actually fine.

@gsserge gsserge merged commit feeb77e into master Aug 3, 2021
@gsserge gsserge mentioned this pull request Aug 3, 2021
@gsserge gsserge deleted the optional_tokio branch August 3, 2021 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants