Skip to content

Commit

Permalink
feat(docs): add doc_cfg for feature-specific items
Browse files Browse the repository at this point in the history
Signed-off-by: vados <vados@vadosware.io>
  • Loading branch information
t3hmrman committed Jul 28, 2023
1 parent fb73d2e commit aeb2b45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
//! });
//! }
//! ```
//!
//! The example above demonstrates the synchronous usage, but `tokio` and `async-std` and corresponding modules are available as well.

use std::{result::Result, time::Duration};

Expand Down
3 changes: 3 additions & 0 deletions src/runtime/async_std.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg(feature = "async-std")]
#![feature(doc_cfg)]

use std::{error::Error, future::Future, time::Instant};

Expand All @@ -10,6 +11,7 @@ use crate::{AsyncSituwaition, SituwaitionError};
use super::AsyncWaiter;

#[async_trait]
#![doc(cfg(feature = "async-std"))]
impl<F, A, R, E> AsyncSituwaition for AsyncWaiter<F, A, R, E>
where
F: Future<Output = Result<R, E>> + Send,
Expand Down Expand Up @@ -52,6 +54,7 @@ where
/// Returning a result (as opposed to the error) will end waiting, otherwise
/// the function will be retried up until the default timeout (see SituwaitionOpts)
#[allow(dead_code)]
#![doc(cfg(feature = "async-std"))]
pub async fn wait_for<R, E, F, G>(factory: F) -> Result<R, SituwaitionError<E>>
where
R: Send + Sync + 'static,
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/tokio.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg(feature = "tokio")]
#![feature(doc_cfg)]

use std::{error::Error, future::Future};

Expand All @@ -10,6 +11,7 @@ use crate::{AsyncSituwaition, SituwaitionError};
use super::AsyncWaiter;

#[async_trait]
#![doc(cfg(feature = "tokio"))]
impl<F, A, R, E> AsyncSituwaition for AsyncWaiter<F, A, R, E>
where
F: Future<Output = Result<R, E>> + Send,
Expand Down Expand Up @@ -52,6 +54,7 @@ where
/// Returning a result (as opposed to the error) will end waiting, otherwise
/// the function will be retried up until the default timeout (see SituwaitionOpts)
#[allow(dead_code)]
#![doc(cfg(feature = "tokio"))]
pub async fn wait_for<R, E, F, G>(factory: F) -> Result<R, SituwaitionError<E>>
where
R: Send + Sync + 'static,
Expand Down

0 comments on commit aeb2b45

Please sign in to comment.