@@ -143,17 +143,17 @@ impl BorrowedHandle<'_> {
143143}
144144
145145impl TryFrom < HandleOrNull > for OwnedHandle {
146- type Error = NotHandle ;
146+ type Error = NullHandleError ;
147147
148148 #[ inline]
149- fn try_from ( handle_or_null : HandleOrNull ) -> Result < Self , NotHandle > {
149+ fn try_from ( handle_or_null : HandleOrNull ) -> Result < Self , NullHandleError > {
150150 let owned_handle = handle_or_null. 0 ;
151151 if owned_handle. handle . is_null ( ) {
152152 // Don't call `CloseHandle`; it'd be harmless, except that it could
153153 // overwrite the `GetLastError` error.
154154 forget ( owned_handle) ;
155155
156- Err ( NotHandle ( ( ) ) )
156+ Err ( NullHandleError ( ( ) ) )
157157 } else {
158158 Ok ( owned_handle)
159159 }
@@ -201,39 +201,56 @@ impl OwnedHandle {
201201}
202202
203203impl TryFrom < HandleOrInvalid > for OwnedHandle {
204- type Error = NotHandle ;
204+ type Error = InvalidHandleError ;
205205
206206 #[ inline]
207- fn try_from ( handle_or_invalid : HandleOrInvalid ) -> Result < Self , NotHandle > {
207+ fn try_from ( handle_or_invalid : HandleOrInvalid ) -> Result < Self , InvalidHandleError > {
208208 let owned_handle = handle_or_invalid. 0 ;
209209 if owned_handle. handle == c:: INVALID_HANDLE_VALUE {
210210 // Don't call `CloseHandle`; it'd be harmless, except that it could
211211 // overwrite the `GetLastError` error.
212212 forget ( owned_handle) ;
213213
214- Err ( NotHandle ( ( ) ) )
214+ Err ( InvalidHandleError ( ( ) ) )
215215 } else {
216216 Ok ( owned_handle)
217217 }
218218 }
219219}
220220
221- /// This is the error type used by [`HandleOrInvalid`] and
222- /// [`HandleOrNull`] when attempting to convert into a handle,
223- /// to indicate that the value is not a handle.
221+ /// This is the error type used by [`HandleOrNull`] when attempting to convert
222+ /// into a handle, to indicate that the value is null.
224223#[ unstable( feature = "io_safety" , issue = "87074" ) ]
225- #[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
226- pub struct NotHandle ( ( ) ) ;
224+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
225+ pub struct NullHandleError ( ( ) ) ;
227226
228227#[ unstable( feature = "io_safety" , issue = "87074" ) ]
229- impl fmt:: Display for NotHandle {
228+ impl fmt:: Display for NullHandleError {
230229 fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
231- "the return value of a Windows API call indicated an error " . fmt ( fmt)
230+ "A HandleOrNull could not be converted to a handle because it was null " . fmt ( fmt)
232231 }
233232}
234233
235234#[ unstable( feature = "io_safety" , issue = "87074" ) ]
236- impl crate :: error:: Error for NotHandle { }
235+ impl crate :: error:: Error for NullHandleError { }
236+
237+ /// This is the error type used by [`HandleOrInvalid`] when attempting to
238+ /// convert into a handle, to indicate that the value is
239+ /// `INVALID_HANDLE_VALUE`.
240+ #[ unstable( feature = "io_safety" , issue = "87074" ) ]
241+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
242+ pub struct InvalidHandleError ( ( ) ) ;
243+
244+ #[ unstable( feature = "io_safety" , issue = "87074" ) ]
245+ impl fmt:: Display for InvalidHandleError {
246+ fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
247+ "A HandleOrInvalid could not be converted to a handle because it was INVALID_HANDLE_VALUE"
248+ . fmt ( fmt)
249+ }
250+ }
251+
252+ #[ unstable( feature = "io_safety" , issue = "87074" ) ]
253+ impl crate :: error:: Error for InvalidHandleError { }
237254
238255impl AsRawHandle for BorrowedHandle < ' _ > {
239256 #[ inline]
0 commit comments