Skip to content

Commit e7fd1ae

Browse files
authored
feat(executor): implement std::io::Error conversion for JoinError (#918)
1 parent b06ff34 commit e7fd1ae

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

compio-executor/src/join_handle.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{
22
error::Error,
33
fmt::Display,
4+
io,
45
marker::PhantomData,
56
mem::ManuallyDrop,
67
panic::resume_unwind,
@@ -104,6 +105,15 @@ impl Display for JoinError {
104105

105106
impl Error for JoinError {}
106107

108+
impl From<JoinError> for io::Error {
109+
fn from(e: JoinError) -> Self {
110+
match e {
111+
JoinError::Cancelled => io::Error::other("Task was cancelled"),
112+
JoinError::Panicked(_) => io::Error::other("Task has panicked"),
113+
}
114+
}
115+
}
116+
107117
impl<T> Future for JoinHandle<T> {
108118
type Output = Result<T, JoinError>;
109119

0 commit comments

Comments
 (0)