small refactoring (#6531)

This commit is contained in:
Thomas Coratger
2024-02-10 22:21:40 +01:00
committed by GitHub
parent 1bc75d974d
commit 8cfa5efe62
6 changed files with 21 additions and 35 deletions

View File

@ -74,10 +74,7 @@ impl TransportReceiverT for Receiver {
/// Returns a Future resolving when the server sent us something back.
async fn receive(&mut self) -> Result<ReceivedMessage, Self::Error> {
match self.inner.next().await {
None => Err(IpcError::Closed),
Some(val) => Ok(ReceivedMessage::Text(val?)),
}
self.inner.next().await.map_or(Err(IpcError::Closed), |val| Ok(ReceivedMessage::Text(val?)))
}
}

View File

@ -35,11 +35,10 @@ where
/// Polls to accept a new incoming connection to the endpoint.
pub(crate) fn poll_accept(&mut self, cx: &mut Context<'_>) -> Poll<<Self as Stream>::Item> {
let res = match ready!(self.poll_next_unpin(cx)) {
None => Err(io::Error::new(io::ErrorKind::ConnectionAborted, "ipc connection closed")),
Some(conn) => conn,
};
Poll::Ready(res)
Poll::Ready(ready!(self.poll_next_unpin(cx)).map_or(
Err(io::Error::new(io::ErrorKind::ConnectionAborted, "ipc connection closed")),
|conn| conn,
))
}
}