@@ -143,17 +143,17 @@ impl BorrowedHandle<'_> {
143
143
}
144
144
145
145
impl TryFrom < HandleOrNull > for OwnedHandle {
146
- type Error = NotHandle ;
146
+ type Error = NullHandleError ;
147
147
148
148
#[ inline]
149
- fn try_from ( handle_or_null : HandleOrNull ) -> Result < Self , NotHandle > {
149
+ fn try_from ( handle_or_null : HandleOrNull ) -> Result < Self , NullHandleError > {
150
150
let owned_handle = handle_or_null. 0 ;
151
151
if owned_handle. handle . is_null ( ) {
152
152
// Don't call `CloseHandle`; it'd be harmless, except that it could
153
153
// overwrite the `GetLastError` error.
154
154
forget ( owned_handle) ;
155
155
156
- Err ( NotHandle ( ( ) ) )
156
+ Err ( NullHandleError ( ( ) ) )
157
157
} else {
158
158
Ok ( owned_handle)
159
159
}
@@ -201,39 +201,56 @@ impl OwnedHandle {
201
201
}
202
202
203
203
impl TryFrom < HandleOrInvalid > for OwnedHandle {
204
- type Error = NotHandle ;
204
+ type Error = InvalidHandleError ;
205
205
206
206
#[ inline]
207
- fn try_from ( handle_or_invalid : HandleOrInvalid ) -> Result < Self , NotHandle > {
207
+ fn try_from ( handle_or_invalid : HandleOrInvalid ) -> Result < Self , InvalidHandleError > {
208
208
let owned_handle = handle_or_invalid. 0 ;
209
209
if owned_handle. handle == c:: INVALID_HANDLE_VALUE {
210
210
// Don't call `CloseHandle`; it'd be harmless, except that it could
211
211
// overwrite the `GetLastError` error.
212
212
forget ( owned_handle) ;
213
213
214
- Err ( NotHandle ( ( ) ) )
214
+ Err ( InvalidHandleError ( ( ) ) )
215
215
} else {
216
216
Ok ( owned_handle)
217
217
}
218
218
}
219
219
}
220
220
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.
224
223
#[ 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 ( ( ) ) ;
227
226
228
227
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
229
- impl fmt:: Display for NotHandle {
228
+ impl fmt:: Display for NullHandleError {
230
229
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)
232
231
}
233
232
}
234
233
235
234
#[ 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 { }
237
254
238
255
impl AsRawHandle for BorrowedHandle < ' _ > {
239
256
#[ inline]
0 commit comments