about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorDan Gohman <dev@sunfishcode.online>2022-02-10 18:26:12 -0800
committerDan Gohman <dev@sunfishcode.online>2022-02-10 18:26:12 -0800
commit1f98ef7793dde6c3a3c216d55ae5858da7e0c34e (patch)
tree464a175b6c7276400c9986c3d5a924ac109188c2 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent502d6aa47b4118fea1e326529e71b25a99b0d6c5 (diff)
downloadrust-1f98ef7793dde6c3a3c216d55ae5858da7e0c34e.tar.gz
rust-1f98ef7793dde6c3a3c216d55ae5858da7e0c34e.zip
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`.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions