Skip to content

Commit

Permalink
Remove Stream feature
Browse files Browse the repository at this point in the history
  • Loading branch information
DoumanAsh committed Oct 27, 2023
1 parent a34ad9f commit 2b852c7
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
run: cargo test --features tokio1 -- --nocapture

- name: Test
run: cargo test --all --features std,stream
run: cargo test --all --features std

- name: Test with C wrapper
if: runner.os == 'Linux'
Expand Down
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ std = ["error-code/std"]
c_wrapper = ["cc"]
# Enables usage of tokio 1.0
tokio1 = ["tokio_1", "std"]
# Enables Stream implementation
stream = ["futures-core"]

[dependencies]
error-code = "3"
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ give you the most accurate timers possible on unix platforms (See features.)
- `tokio1` - Enables event loop based timers using tokio, providing higher resolution timers on unix platforms.
- `c_wrapper` - Uses C shim to create bindings to platform API, which may be more reliable than `libc`.
- `std` - Enables usage of std types (e.g. Error)
- `stream` - Enables `Stream` implementation for `Interval`

## Examples

Expand Down
11 changes: 0 additions & 11 deletions src/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,3 @@ impl<T: Timer> Future for &'_ mut Interval<T> {
}
}
}

#[cfg(feature = "stream")]
impl<T: Timer> futures_core::stream::Stream for Interval<T> {
type Item = ();

#[inline]
fn poll_next(self: Pin<&mut Self>, ctx: &mut task::Context) -> task::Poll<Option<Self::Item>> {
let mut this = self.get_mut();
Future::poll(Pin::new(&mut this), ctx).map(|res| Some(res))
}
}
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
//! - `tokio1` - Enables event loop based timers using tokio, providing higher resolution timers on unix platforms.
//! - `c_wrapper` - Uses C shim to create bindings to platform API, which may be more reliable than `libc`.
//! - `std` - Enables usage of std types (e.g. Error)
//! - `stream` - Enables `Stream` implementation for `Interval`
#![warn(missing_docs)]

#![no_std]
Expand Down
48 changes: 1 addition & 47 deletions tests/interval.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use async_timer::{Interval};
use async_timer::Interval;
use tokio_1 as tokio;

use std::time;
Expand All @@ -21,49 +21,3 @@ async fn test_interval() {

assert!(diff.as_millis() >= 750 && diff.as_millis() <= 1_250);
}

#[cfg(feature = "stream")]
#[tokio::test]
async fn test_stream_interval() {
use futures_core::Stream;
use core::future::Future;
use core::pin::Pin;
use core::task;

pub struct Next<'a, S> {
stream: &'a mut S,
}

impl<'a, S> Next<'a, S> {
fn new(stream: &'a mut S) -> Self {
Self {
stream,
}
}
}

impl<S: Stream + Unpin> Future for Next<'_, S> {
type Output = Option<S::Item>;

fn poll(mut self: Pin<&mut Self>, ctx: &mut task::Context<'_>) -> task::Poll<Self::Output> {
let stream = Pin::new(&mut self.stream);
stream.poll_next(ctx)
}
}

let mut interval = Interval::platform_new(time::Duration::from_secs(1));

let before = time::SystemTime::now();
Next::new(&mut interval).await;
let after = time::SystemTime::now();
let diff = after.duration_since(before).unwrap();

assert!(diff.as_millis() >= 750 && diff.as_millis() <= 1_250);

let before = time::SystemTime::now();
Next::new(&mut interval).await;
let after = time::SystemTime::now();
let diff = after.duration_since(before).unwrap();

assert!(diff.as_millis() >= 750 && diff.as_millis() <= 1_250);
}

0 comments on commit 2b852c7

Please sign in to comment.