Use the new impl AsFd for &T support in io-lifetimes.#232
Merged
Conversation
With rust-lang/rust#93888 now in nightly, and sunfishcode/io-lifetimes#18 now in io-lifetimes 0.5.2, we can now simplify the `AsFd` pattern from `fn foo<Fd: AsFd>(fd: &Fd)` to `fn foo<Fd: AsFd>(fd: Fd)`, without the `&`. This also follows the emerging convention in std, as seen in the new [`fchown`] function. This means that users can now pass `BorrowedFd` values directly to functions that expect `AsFd` arguments, without having to write an extra `&` when passing them. [`fchown`]: https://doc.rust-lang.org/nightly/std/os/unix/fs/fn.fchown.html
206a66b to
1ef0865
Compare
…is-terminal`. is-terminal is implemented in terms of rustix, so the code was previously just testing rustix against itself, and creating an awkward circluar dependency besides. Test against `libc::isatty` and `ioctl_tiocgwinsz` instead.
cgwalters
approved these changes
Feb 17, 2022
Contributor
cgwalters
left a comment
There was a problem hiding this comment.
Oh nice, this looks a lot better! I was confused by the need to & a BorrowedFd indeed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With rust-lang/rust#93888 now in nightly, and sunfishcode/io-lifetimes#18 now
in io-lifetimes 0.5.2, we can now simplify the
AsFdpattern fromfn foo<Fd: AsFd>(fd: &Fd)tofn foo<Fd: AsFd>(fd: Fd), without the&.This also follows the emerging convention in std, as seen in the new
fchownfunction.This means that users can now pass
BorrowedFdvalues directly tofunctions that expect
AsFdarguments, without having to write anextra
&when passing them.