mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
net: use std::future::ready instead of own Ready future (#4271)
This commit is contained in:
parent
02141db1e1
commit
ac0f894dd9
@ -8,11 +8,6 @@ pub(crate) mod maybe_done;
|
||||
mod poll_fn;
|
||||
pub use poll_fn::poll_fn;
|
||||
|
||||
cfg_not_loom! {
|
||||
mod ready;
|
||||
pub(crate) use ready::{ok, Ready};
|
||||
}
|
||||
|
||||
cfg_process! {
|
||||
mod try_join;
|
||||
pub(crate) use try_join::try_join3;
|
||||
|
@ -1,27 +0,0 @@
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
/// Future for the [`ok`](ok()) function.
|
||||
///
|
||||
/// `pub` in order to use the future as an associated type in a sealed trait.
|
||||
#[derive(Debug)]
|
||||
// Used as an associated type in a "sealed" trait.
|
||||
#[allow(unreachable_pub)]
|
||||
pub struct Ready<T>(Option<T>);
|
||||
|
||||
impl<T> Unpin for Ready<T> {}
|
||||
|
||||
impl<T> Future for Ready<T> {
|
||||
type Output = T;
|
||||
|
||||
#[inline]
|
||||
fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
|
||||
Poll::Ready(self.0.take().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a future that is immediately ready with a success value.
|
||||
pub(crate) fn ok<T, E>(t: T) -> Ready<Result<T, E>> {
|
||||
Ready(Some(Ok(t)))
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
use crate::future;
|
||||
|
||||
use std::future;
|
||||
use std::io;
|
||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||
|
||||
@ -56,7 +55,7 @@ impl sealed::ToSocketAddrsPriv for SocketAddr {
|
||||
|
||||
fn to_socket_addrs(&self, _: sealed::Internal) -> Self::Future {
|
||||
let iter = Some(*self).into_iter();
|
||||
future::ok(iter)
|
||||
future::ready(Ok(iter))
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +95,7 @@ impl sealed::ToSocketAddrsPriv for (IpAddr, u16) {
|
||||
|
||||
fn to_socket_addrs(&self, _: sealed::Internal) -> Self::Future {
|
||||
let iter = Some(SocketAddr::from(*self)).into_iter();
|
||||
future::ok(iter)
|
||||
future::ready(Ok(iter))
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +137,7 @@ impl sealed::ToSocketAddrsPriv for &[SocketAddr] {
|
||||
|
||||
fn to_socket_addrs(&self, _: sealed::Internal) -> Self::Future {
|
||||
let iter = self.to_vec().into_iter();
|
||||
future::ok(iter)
|
||||
future::ready(Ok(iter))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user