File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
library/std/src/os/windows/io Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,13 @@ pub struct BorrowedHandle<'handle> {
4747/// `INVALID_HANDLE_VALUE` instead of null, use [`OptionFileHandle`] instead
4848/// of `Option<OwnedHandle>`.
4949///
50+ /// `OwnedHandle` uses [`CloseHandle`] to close its handle on drop. As such,
51+ /// it must not be used with handles to open registry keys which need to be
52+ /// closed with [`RegCloseKey`] instead.
53+ ///
54+ /// [`CloseHandle`]: https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle
55+ /// [`RegCloseKey`]: https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey
56+ ///
5057/// [here]: https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443
5158#[ repr( transparent) ]
5259#[ unstable( feature = "io_safety" , issue = "87074" ) ]
@@ -178,8 +185,14 @@ impl FromRawHandle for OwnedHandle {
178185 ///
179186 /// # Safety
180187 ///
181- /// The resource pointed to by `raw` must be open and suitable for assuming
182- /// ownership. The resource must not require any cleanup other than `CloseHandle`.
188+ /// The resource pointed to by `raw` must be open and suitable for
189+ /// assuming ownership. The resource must not require any cleanup other
190+ /// than `CloseHandle`.
191+ ///
192+ /// In particular, it must not be used with handles to open registry
193+ /// keys which need to be closed with [`RegCloseKey`] instead.
194+ ///
195+ /// [`RegCloseKey`]: https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey
183196 #[ inline]
184197 unsafe fn from_raw_handle ( raw : RawHandle ) -> Self {
185198 assert ! ( !raw. is_null( ) ) ;
You can’t perform that action at this time.
0 commit comments