@@ -142,17 +142,17 @@ impl BorrowedHandle<'_> {
142
142
}
143
143
144
144
impl TryFrom < HandleOrNull > for OwnedHandle {
145
- type Error = NotHandle ;
145
+ type Error = NullHandleError ;
146
146
147
147
#[ inline]
148
- fn try_from ( handle_or_null : HandleOrNull ) -> Result < Self , NotHandle > {
148
+ fn try_from ( handle_or_null : HandleOrNull ) -> Result < Self , NullHandleError > {
149
149
let owned_handle = handle_or_null. 0 ;
150
150
if owned_handle. handle . is_null ( ) {
151
151
// Don't call `CloseHandle`; it'd be harmless, except that it could
152
152
// overwrite the `GetLastError` error.
153
153
forget ( owned_handle) ;
154
154
155
- Err ( NotHandle ( ( ) ) )
155
+ Err ( NullHandleError ( ( ) ) )
156
156
} else {
157
157
Ok ( owned_handle)
158
158
}
@@ -200,39 +200,56 @@ impl OwnedHandle {
200
200
}
201
201
202
202
impl TryFrom < HandleOrInvalid > for OwnedHandle {
203
- type Error = NotHandle ;
203
+ type Error = InvalidHandleError ;
204
204
205
205
#[ inline]
206
- fn try_from ( handle_or_invalid : HandleOrInvalid ) -> Result < Self , NotHandle > {
206
+ fn try_from ( handle_or_invalid : HandleOrInvalid ) -> Result < Self , InvalidHandleError > {
207
207
let owned_handle = handle_or_invalid. 0 ;
208
208
if owned_handle. handle == c:: INVALID_HANDLE_VALUE {
209
209
// Don't call `CloseHandle`; it'd be harmless, except that it could
210
210
// overwrite the `GetLastError` error.
211
211
forget ( owned_handle) ;
212
212
213
- Err ( NotHandle ( ( ) ) )
213
+ Err ( InvalidHandleError ( ( ) ) )
214
214
} else {
215
215
Ok ( owned_handle)
216
216
}
217
217
}
218
218
}
219
219
220
- /// This is the error type used by [`HandleOrInvalid`] and
221
- /// [`HandleOrNull`] when attempting to convert into a handle,
222
- /// to indicate that the value is not a handle.
220
+ /// This is the error type used by [`HandleOrNull`] when attempting to convert
221
+ /// into a handle, to indicate that the value is null.
223
222
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
224
- #[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
225
- pub struct NotHandle ( ( ) ) ;
223
+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
224
+ pub struct NullHandleError ( ( ) ) ;
226
225
227
226
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
228
- impl fmt:: Display for NotHandle {
227
+ impl fmt:: Display for NullHandleError {
229
228
fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
230
- "the return value of a Windows API call indicated an error " . fmt ( fmt)
229
+ "A HandleOrNull could not be converted to a handle because it was null " . fmt ( fmt)
231
230
}
232
231
}
233
232
234
233
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
235
- impl crate :: error:: Error for NotHandle { }
234
+ impl crate :: error:: Error for NullHandleError { }
235
+
236
+ /// This is the error type used by [`HandleOrInvalid`] when attempting to
237
+ /// convert into a handle, to indicate that the value is
238
+ /// `INVALID_HANDLE_VALUE`.
239
+ #[ unstable( feature = "io_safety" , issue = "87074" ) ]
240
+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
241
+ pub struct InvalidHandleError ( ( ) ) ;
242
+
243
+ #[ unstable( feature = "io_safety" , issue = "87074" ) ]
244
+ impl fmt:: Display for InvalidHandleError {
245
+ fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
246
+ "A HandleOrInvalid could not be converted to a handle because it was INVALID_HANDLE_VALUE"
247
+ . fmt ( fmt)
248
+ }
249
+ }
250
+
251
+ #[ unstable( feature = "io_safety" , issue = "87074" ) ]
252
+ impl crate :: error:: Error for InvalidHandleError { }
236
253
237
254
impl AsRawHandle for BorrowedHandle < ' _ > {
238
255
#[ inline]
0 commit comments