rust/library/std/src/os
Dan Gohman 1f98ef7793 Implement AsFd for &T and &mut T.
Add implementations of `AsFd` for `&T` and `&mut T`, so that users can
write code like this:

```rust
pub fn fchown<F: AsFd>(fd: F, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> {
```

with `fd: F` rather than `fd: &F`.

And similar for `AsHandle` and `AsSocket` on Windows.

Also, adjust the `fchown` example to pass the file by reference. The
code can work either way now, but passing by reference is more likely
to be what users will want to do.

This is an alternative to #93869, and is a simpler way to achieve the
same goals: users don't need to pass borrowed-`BorrowedFd` arguments,
and it prevents a pitfall in the case where users write `fd: F` instead
of `fd: &F`.
2022-02-10 18:26:12 -08:00
..
android Switch to intra-doc links in library/std/src/os/*/fs.rs 2020-08-11 15:20:01 +05:30
dragonfly Switch to intra-doc links in library/std/src/os/*/fs.rs 2020-08-11 15:20:01 +05:30
emscripten Remove an invalid #[doc(inline)] 2021-05-11 00:03:44 +02:00
espidf STD support for the ESP-IDF framework 2021-08-10 12:09:00 +03:00
fd Implement AsFd for &T and &mut T. 2022-02-10 18:26:12 -08:00
fortanix_sgx Stabilize asm! and global_asm! 2021-12-12 11:20:03 +00:00
freebsd Auto merge of #74576 - myfreeweb:freebsd-sanitizers, r=oli-obk 2020-08-15 11:38:24 +00:00
fuchsia Switch to intra-doc links in library/std/src/os/*/fs.rs 2020-08-11 15:20:01 +05:30
haiku Deprecate std::os::haiku::raw 2021-03-16 17:43:33 -04:00
hermit Move OsStringExt and OsStrExt to std::os 2021-06-20 11:55:01 +02:00
illumos Switch to intra-doc links in library/std/src/os/*/fs.rs 2020-08-11 15:20:01 +05:30
ios Switch to intra-doc links in library/std/src/os/*/fs.rs 2020-08-11 15:20:01 +05:30
linux Compute most of Public/Exported access level in rustc_resolve 2022-01-09 21:33:14 +00:00
macos Switch to intra-doc links in library/std/src/os/*/fs.rs 2020-08-11 15:20:01 +05:30
netbsd Switch to intra-doc links in library/std/src/os/*/fs.rs 2020-08-11 15:20:01 +05:30
openbsd Switch to intra-doc links in library/std/src/os/*/fs.rs 2020-08-11 15:20:01 +05:30
raw Work around Clippy false positive on as c_char 2021-12-07 22:33:31 -08:00
redox Cleanup std::os 2021-05-03 16:56:20 +02:00
solaris Switch to intra-doc links in library/std/src/os/*/fs.rs 2020-08-11 15:20:01 +05:30
solid Add SOLID targets 2021-09-28 11:31:47 +09:00
unix Implement AsFd for &T and &mut T. 2022-02-10 18:26:12 -08:00
vxworks Take sys/vxworks/{fd,fs,io} from sys/unix instead. 2020-10-16 06:19:00 +02:00
wasi Hide Repr details from io::Error, and rework io::Error::new_const. 2022-02-04 18:47:29 -08:00
windows Implement AsFd for &T and &mut T. 2022-02-10 18:26:12 -08:00
mod.rs Add SOLID targets 2021-09-28 11:31:47 +09:00