Skip to content

Commit 12312fa

Browse files
Add I/O safety details
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
1 parent 669e5ed commit 12312fa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

posts/2022-08-11-Rust-1.63.0.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ Please [report] any bugs you might come across!
3232

3333
Previously, Rust code working with platform APIs taking raw file descriptors (on
3434
unix-style platforms) or handles (on Windows) would typically work directly with
35-
a platform-specific representation of the descriptor (for example, a `c_int`).
35+
a platform-specific representation of the descriptor (for example, a `c_int`, or the alias `RawFd`).
3636
For Rust bindings to such native APIs, the type system then failed to encode
3737
whether the API would take ownership of the file descriptor (e.g., `close`) or
3838
merely borrow it (e.g., `dup`).
3939

40-
Now, Rust provides wrapper types such as [`BorrowedFd`], which are marked as
40+
Now, Rust provides wrapper types such as [`BorrowedFd`] and [`OwnedFd`], which are marked as
4141
`#[repr(transparent)]`, meaning that `extern "C"` bindings can directly take
4242
these types to encode the ownership semantics. See the stabilized APIs section
4343
for the full list of wrapper types stabilized in 1.63, currently, they are
@@ -48,6 +48,7 @@ We recommend that new APIs use these types instead of the previous type aliases
4848

4949
[`RawFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/type.RawFd.html
5050
[`BorrowedFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/struct.BorrowedFd.html
51+
[`OwnedFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/struct.OwnedFd.html
5152

5253
### Turbofish for generics in functions with `impl Trait`
5354

0 commit comments

Comments
 (0)