about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-02-11 21:48:50 +0100
committerGitHub <noreply@github.com>2022-02-11 21:48:50 +0100
commit34997f0114e30ebf81e38ab44b1a1e0ce55297ad (patch)
tree4a15fdf261ed078dd3ed2713e3dee5022e0245b7 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parentdb7124839cde4cc53410833d9ffaca5f4acd2570 (diff)
parent1f98ef7793dde6c3a3c216d55ae5858da7e0c34e (diff)
downloadrust-34997f0114e30ebf81e38ab44b1a1e0ce55297ad.tar.gz
rust-34997f0114e30ebf81e38ab44b1a1e0ce55297ad.zip
Rollup merge of #93888 - sunfishcode:sunfishcode/impl-asfd-for-ref, r=joshtriplett
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`.

r? ```@joshtriplett```
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions