Skip to content

Commit 25e8610

Browse files
committed
Use std::future::poll_fn instead of futures_lite::future::poll_fn
1 parent 714aecc commit 25e8610

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
html_logo_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png"
6262
)]
6363

64-
use std::future::Future;
64+
use std::future::{poll_fn, Future};
6565
use std::io::{self, IoSlice, IoSliceMut, Read, Write};
6666
use std::net::{SocketAddr, TcpListener, TcpStream, UdpSocket};
6767
use std::pin::{pin, Pin};
@@ -80,7 +80,6 @@ use std::{
8080
use std::os::windows::io::{AsRawSocket, AsSocket, BorrowedSocket, OwnedSocket, RawSocket};
8181

8282
use futures_io::{AsyncRead, AsyncWrite};
83-
use futures_lite::future;
8483
use futures_lite::stream::{self, Stream};
8584

8685
use rustix::io as rio;
@@ -955,14 +954,14 @@ impl<T> Async<T> {
955954
///
956955
/// ```no_run
957956
/// use async_io::Async;
958-
/// use futures_lite::future;
957+
/// use std::future::poll_fn;
959958
/// use std::net::TcpListener;
960959
///
961960
/// # futures_lite::future::block_on(async {
962961
/// let mut listener = Async::<TcpListener>::bind(([127, 0, 0, 1], 0))?;
963962
///
964963
/// // Wait until a client can be accepted.
965-
/// future::poll_fn(|cx| listener.poll_readable(cx)).await?;
964+
/// poll_fn(|cx| listener.poll_readable(cx)).await?;
966965
/// # std::io::Result::Ok(()) });
967966
/// ```
968967
pub fn poll_readable(&self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
@@ -986,15 +985,15 @@ impl<T> Async<T> {
986985
///
987986
/// ```
988987
/// use async_io::Async;
989-
/// use futures_lite::future;
988+
/// use std::future::poll_fn;
990989
/// use std::net::{TcpStream, ToSocketAddrs};
991990
///
992991
/// # futures_lite::future::block_on(async {
993992
/// let addr = "example.com:80".to_socket_addrs()?.next().unwrap();
994993
/// let stream = Async::<TcpStream>::connect(addr).await?;
995994
///
996995
/// // Wait until the stream is writable.
997-
/// future::poll_fn(|cx| stream.poll_writable(cx)).await?;
996+
/// poll_fn(|cx| stream.poll_writable(cx)).await?;
998997
/// # std::io::Result::Ok(()) });
999998
/// ```
1000999
pub fn poll_writable(&self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
@@ -2059,7 +2058,7 @@ async fn optimistic(fut: impl Future<Output = io::Result<()>>) -> io::Result<()>
20592058
let mut polled = false;
20602059
let mut fut = pin!(fut);
20612060

2062-
future::poll_fn(|cx| {
2061+
poll_fn(|cx| {
20632062
if !polled {
20642063
polled = true;
20652064
fut.as_mut().poll(cx)

src/os/kqueue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,16 @@ impl<T> Filter<T> {
183183
/// # Examples
184184
///
185185
/// ```no_run
186-
/// use std::process::Command;
187186
/// use async_io::os::kqueue::{Exit, Filter};
188-
/// use futures_lite::future;
187+
/// use std::future::poll_fn;
188+
/// use std::process::Command;
189189
///
190190
/// # futures_lite::future::block_on(async {
191191
/// let child = Command::new("sleep").arg("5").spawn()?;
192192
/// let process = Filter::new(Exit::new(child))?;
193193
///
194194
/// // Wait for the process to exit.
195-
/// future::poll_fn(|cx| process.poll_ready(cx)).await?;
195+
/// poll_fn(|cx| process.poll_ready(cx)).await?;
196196
/// # std::io::Result::Ok(()) });
197197
/// ```
198198
pub fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<()>> {

src/os/windows.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,16 @@ impl<T> Waitable<T> {
160160
/// # Examples
161161
///
162162
/// ```no_run
163-
/// use std::process::Command;
164163
/// use async_io::os::windows::Waitable;
165-
/// use futures_lite::future;
164+
/// use std::future::poll_fn;
165+
/// use std::process::Command;
166166
///
167167
/// # futures_lite::future::block_on(async {
168168
/// let child = Command::new("sleep").arg("5").spawn()?;
169169
/// let process = Waitable::new(child)?;
170170
///
171171
/// // Wait for the process to exit.
172-
/// future::poll_fn(|cx| process.poll_ready(cx)).await?;
172+
/// poll_fn(|cx| process.poll_ready(cx)).await?;
173173
/// # std::io::Result::Ok(()) });
174174
/// ```
175175
pub fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<()>> {

tests/timer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::future::Future;
1+
use std::future::{poll_fn, Future};
22
use std::pin::Pin;
33
use std::sync::{Arc, Mutex};
44
use std::thread;
@@ -91,7 +91,7 @@ fn set() {
9191
}
9292
});
9393

94-
future::poll_fn(|cx| Pin::new(&mut *timer.lock().unwrap()).poll(cx)).await;
94+
poll_fn(|cx| Pin::new(&mut *timer.lock().unwrap()).poll(cx)).await;
9595

9696
assert!(start.elapsed() >= Duration::from_secs(2));
9797
assert!(start.elapsed() < Duration::from_secs(10));

0 commit comments

Comments
 (0)