@@ -4,7 +4,7 @@ use crate::coroutine::listener::Listener;
44use crate :: coroutine:: Coroutine ;
55use crate :: { error, info} ;
66use std:: fmt:: Debug ;
7- use std:: io:: { Error , ErrorKind } ;
7+ use std:: io:: Error ;
88
99impl < Param , Yield , Return > Coroutine < ' _ , Param , Yield , Return >
1010where
@@ -45,14 +45,11 @@ where
4545 }
4646 _ => { }
4747 }
48- Err ( Error :: new (
49- ErrorKind :: Other ,
50- format ! (
51- "{} unexpected {current}->{:?}" ,
52- self . name( ) ,
53- CoroutineState :: <Yield , Return >:: Ready
54- ) ,
55- ) )
48+ Err ( Error :: other ( format ! (
49+ "{} unexpected {current}->{:?}" ,
50+ self . name( ) ,
51+ CoroutineState :: <Yield , Return >:: Ready
52+ ) ) )
5653 }
5754
5855 /// ready -> running
@@ -87,14 +84,11 @@ where
8784 }
8885 _ => { }
8986 }
90- Err ( Error :: new (
91- ErrorKind :: Other ,
92- format ! (
93- "{} unexpected {current}->{:?}" ,
94- self . name( ) ,
95- CoroutineState :: <Yield , Return >:: Running
96- ) ,
97- ) )
87+ Err ( Error :: other ( format ! (
88+ "{} unexpected {current}->{:?}" ,
89+ self . name( ) ,
90+ CoroutineState :: <Yield , Return >:: Running
91+ ) ) )
9892 }
9993
10094 /// running -> suspend
@@ -109,14 +103,11 @@ where
109103 self . on_suspend ( self , old_state) ;
110104 return Ok ( ( ) ) ;
111105 }
112- Err ( Error :: new (
113- ErrorKind :: Other ,
114- format ! (
115- "{} unexpected {current}->{:?}" ,
116- self . name( ) ,
117- CoroutineState :: <Yield , Return >:: Suspend ( val, timestamp)
118- ) ,
119- ) )
106+ Err ( Error :: other ( format ! (
107+ "{} unexpected {current}->{:?}" ,
108+ self . name( ) ,
109+ CoroutineState :: <Yield , Return >:: Suspend ( val, timestamp)
110+ ) ) )
120111 }
121112
122113 /// running -> syscall
@@ -148,14 +139,11 @@ where
148139 }
149140 _ => { }
150141 }
151- Err ( Error :: new (
152- ErrorKind :: Other ,
153- format ! (
154- "{} unexpected {current}->{:?}" ,
155- self . name( ) ,
156- CoroutineState :: <Yield , Return >:: Syscall ( val, syscall, syscall_state)
157- ) ,
158- ) )
142+ Err ( Error :: other ( format ! (
143+ "{} unexpected {current}->{:?}" ,
144+ self . name( ) ,
145+ CoroutineState :: <Yield , Return >:: Syscall ( val, syscall, syscall_state)
146+ ) ) )
159147 }
160148
161149 /// running -> complete
@@ -170,14 +158,11 @@ where
170158 self . on_complete ( self , old_state, val) ;
171159 return Ok ( ( ) ) ;
172160 }
173- Err ( Error :: new (
174- ErrorKind :: Other ,
175- format ! (
176- "{} unexpected {current}->{:?}" ,
177- self . name( ) ,
178- CoroutineState :: <Yield , Return >:: Complete ( val)
179- ) ,
180- ) )
161+ Err ( Error :: other ( format ! (
162+ "{} unexpected {current}->{:?}" ,
163+ self . name( ) ,
164+ CoroutineState :: <Yield , Return >:: Complete ( val)
165+ ) ) )
181166 }
182167
183168 /// running -> error
@@ -192,14 +177,11 @@ where
192177 self . on_error ( self , old_state, msg) ;
193178 return Ok ( ( ) ) ;
194179 }
195- Err ( Error :: new (
196- ErrorKind :: Other ,
197- format ! (
198- "{} unexpected {current}->{:?}" ,
199- self . name( ) ,
200- CoroutineState :: <Yield , Return >:: Error ( msg)
201- ) ,
202- ) )
180+ Err ( Error :: other ( format ! (
181+ "{} unexpected {current}->{:?}" ,
182+ self . name( ) ,
183+ CoroutineState :: <Yield , Return >:: Error ( msg)
184+ ) ) )
203185 }
204186}
205187
0 commit comments