]> git.lizzy.rs Git - rust.git/commit
`impl<T: AsRawFd> for {Arc,Box}<T>`
authorJoshua Nelson <jnelson@cloudflare.com>
Thu, 26 May 2022 20:10:46 +0000 (15:10 -0500)
committerJoshua Nelson <jnelson@cloudflare.com>
Wed, 22 Jun 2022 04:03:55 +0000 (23:03 -0500)
commited1e3512dc5e0b25c693b95f39281c97c7bd3819
treee8f9df643aa4186387a055baf38edfac75bcfe04
parent3a8b0144c82197a70e919ad371d56f82c2282833
`impl<T: AsRawFd> for {Arc,Box}<T>`

This allows implementing traits that require a raw FD on Arc and Box.

Previously, you'd have to add the function to the trait itself:

```rust
trait MyTrait {
    fn as_raw_fd(&self) -> RawFd;
}

impl<T: MyTrait> MyTrait for Arc<T> {
    fn as_raw_fd(&self) -> RawFd {
        (**self).as_raw_fd()
    }
}
```
library/std/src/os/fd/raw.rs